summaryrefslogtreecommitdiff
path: root/test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala
diff options
context:
space:
mode:
authorHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
committerHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
commit2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (patch)
tree6ba33d2980a1a7a1286100202a695c6631bd240e /test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala
downloadhands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.gz
hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.bz2
hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.zip
Squashed 'examples/scala-js/' content from commit 47311ba
git-subtree-dir: examples/scala-js git-subtree-split: 47311ba693f949f204f27ea9475bb63425fbd4f3
Diffstat (limited to 'test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala')
-rw-r--r--test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala b/test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala
new file mode 100644
index 0000000..4b2ac62
--- /dev/null
+++ b/test-suite/src/test/scala/scala/scalajs/testsuite/utils/JSUtils.scala
@@ -0,0 +1,26 @@
+package scala.scalajs.testsuite.utils
+
+import scala.scalajs.js
+import js.annotation.JSExport
+
+@JSExport("JSUtils")
+object JSUtils {
+ /* We use java.lang.Character explicitly, because this class is used by
+ * tests that check that Chars are actually boxed by the compiler.
+ * If we rely on the compiler doing the job in here, we might have false
+ * positives just because the value was never boxed, and never unboxed.
+ */
+
+ @JSExport
+ def isChar(c: Any): Boolean = c.isInstanceOf[java.lang.Character]
+
+ @JSExport
+ def stringToChar(s: String): java.lang.Character = {
+ assert(s.length == 1, "makeChar() requires a string of length 1")
+ new java.lang.Character(s.charAt(0))
+ }
+
+ @JSExport
+ def charToString(c: Any): String =
+ c.asInstanceOf[java.lang.Character].toString()
+}