blob: 4b2ac6203a27616d7d24b943aeadabe67d74d175 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
}
|