diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-09 11:48:42 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-09 11:48:42 -0800 |
commit | 159a0093355cb95577879dd3bdc41a28219e3c8a (patch) | |
tree | 4a26041d3e082a5b51419456af8742a08a30bc1c /test/files/run/literals.scala | |
parent | 881048933667dc3e021d557e9f79e0850ac84712 (diff) | |
parent | be553aaa5a765b1d1511688d58f01ec675549412 (diff) | |
download | scala-159a0093355cb95577879dd3bdc41a28219e3c8a.tar.gz scala-159a0093355cb95577879dd3bdc41a28219e3c8a.tar.bz2 scala-159a0093355cb95577879dd3bdc41a28219e3c8a.zip |
Merge pull request #4182 from som-snytt/issue/multizero
SI-9015 Reject 0x and minor parser cleanup
Diffstat (limited to 'test/files/run/literals.scala')
-rw-r--r-- | test/files/run/literals.scala | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 5f23e6b492..13fda05876 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -14,21 +14,16 @@ object Test { def \u03b1\u03b1(that: GGG) = i + that.i } - def check_success[a](name: String, closure: => a, expected: a) { - print("test " + name) - try { - val actual: a = closure - if (actual == expected) { - print(" was successful"); - } else { - print(" failed: expected "+ expected +", found "+ actual); + def check_success[A](name: String, closure: => A, expected: A) { + val res: Option[String] = + try { + val actual: A = closure + if (actual == expected) None //print(" was successful") + else Some(s" failed: expected $expected, found $actual") + } catch { + case exception: Throwable => Some(s" raised exception $exception") } - } catch { - case exception: Throwable => { - print(" raised exception " + exception); - } - } - println + for (e <- res) println(s"test $name $e") } def main(args: Array[String]) { @@ -37,15 +32,14 @@ object Test { check_success("'\\u005f' == '_'", '\u005f', '_') check_success("65.asInstanceOf[Char] == 'A'", 65.asInstanceOf[Char], 'A') check_success("\"\\141\\142\" == \"ab\"", "\141\142", "ab") - check_success("\"\\0x61\\0x62\".trim() == \"x61\\0x62\"", "\0x61\0x62".substring(1), "x61\0x62") - - println + //check_success("\"\\0x61\\0x62\".trim() == \"x61\\0x62\"", "\0x61\0x62".substring(1), "x61\0x62") + check_success(""""\0x61\0x62".getBytes == Array(0, 120, ...)""", + "\0x61\0x62".getBytes(io.Codec.UTF8.charSet) sameElements Array[Byte](0, 120, 54, 49, 0, 120, 54, 50), + true) // boolean check_success("(65 : Byte) == 'A'", (65: Byte) == 'A', true) // contrib #176 - println - // int check_success("0X01 == 1", 0X01, 1) check_success("0x01 == 1", 0x01, 1) @@ -67,8 +61,6 @@ object Test { check_success("0x80000000 == -2147483648", 0x80000000, -2147483648) check_success("0xffffffff == -1", 0xffffffff, -1) - println - // long check_success("1l == 1L", 1l, 1L) check_success("1L == 1l", 1L, 1l) @@ -81,8 +73,6 @@ object Test { check_success("0xffffffffffffffffL == -1L", 0xffffffffffffffffL, -1L) - println - // see JLS at address: // http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798 @@ -97,8 +87,6 @@ object Test { check_success("1.asInstanceOf[Float] == 1.0", 1.asInstanceOf[Float], 1.0f) check_success("1l.asInstanceOf[Float] == 1.0", 1l.asInstanceOf[Float], 1.0f) - println - // double check_success("1e1 == 10.0", 1e1, 10.0) check_success(".3 == 0.3", .3, 0.3) @@ -112,7 +100,6 @@ object Test { check_success("1.asInstanceOf[Double] == 1.0", 1.asInstanceOf[Double], 1.0) check_success("1l.asInstanceOf[Double] == 1.0", 1l.asInstanceOf[Double], 1.0) - println check_success("\"\".length()", "\u001a".length(), 1) val ggg = GGG(1) \u03b1\u03b1 GGG(2) |