diff options
author | michelou <michelou@epfl.ch> | 2004-03-01 17:16:34 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2004-03-01 17:16:34 +0000 |
commit | ffea5d8f789b42735a8bef47151352375dc8d351 (patch) | |
tree | 0547b3578da5e2010868d198af451564dc7dc4fc | |
parent | cda9593740f7986e88800c021b48e0a67ff73b44 (diff) | |
download | scala-ffea5d8f789b42735a8bef47151352375dc8d351.tar.gz scala-ffea5d8f789b42735a8bef47151352375dc8d351.tar.bz2 scala-ffea5d8f789b42735a8bef47151352375dc8d351.zip |
*** empty log message ***
-rw-r--r-- | test/files/run/literals.check | 45 | ||||
-rw-r--r-- | test/files/run/literals.scala | 69 |
2 files changed, 114 insertions, 0 deletions
diff --git a/test/files/run/literals.check b/test/files/run/literals.check index 43bd7101e7..8fd52de35f 100644 --- a/test/files/run/literals.check +++ b/test/files/run/literals.check @@ -1,3 +1,43 @@ +test '\u0024' == '$' was successful +test '\u005f' == '_' was successful +test 65.asInstanceOf[char] == 'A' was successful + +test 01 == 1 was successful +test 010 == 8 was successful +test 0X01 == 1 was successful +test 0x01 == 1 was successful +test 0x10 == 16 was successful +test 0xa == 10 was successful +test 0x0a == 10 was successful +test +01 == 1 was successful +test +010 == 8 was successful +test +0x01 == 1 was successful +test +0x10 == 16 was successful +test +0xa == 10 was successful +test +0x0a == 10 was successful +test -01 == -1 was successful +test -010 == -8 was successful +test -0x01 == -1 was successful +test -0x10 == -16 was successful +test -0xa == -10 was successful +test -0x0a == -10 was successful +test 017777777777 == 2147483647 was successful +test 020000000000 == -2147483648 was successful +test 037777777777 == -1 was successful +test 0x7fffffff == 2147483647 was successful +test 0x80000000 == -2147483648 was successful +test 0xffffffff == -1 was successful + +test 1l == 1L was successful +test 1L == 1l was successful +test 1.asInstanceOf[long] == 1l was successful +test 0777777777777777777777L == 9223372036854775807L was successful +test 01000000000000000000000L == -9223372036854775808L was successful +test 01777777777777777777777L == -1L was successful +test 0x7fffffffffffffffL == 9223372036854775807L was successful +test 0x8000000000000000L == -9223372036854775808L was successful +test 0xffffffffffffffffL == -1L was successful + test 1e1f == 10.0f was successful test 2.f == 2.0f was successful test .3f == 0.3f was successful @@ -5,6 +45,9 @@ test 0f == 0.0f was successful test 3.14f == 3.14f was successful test 6.022e23f == 6.022e23f was successful test 09f == 9.0f was successful +test 1.asInstanceOf[float] == 1.0 was successful +test 1l.asInstanceOf[float] == 1.0 was successful + test 1e1 == 10.0 was successful test 2. == 2.0 was successful test 2.d == 2.0 was successful @@ -14,3 +57,5 @@ test 0d == 0.0 was successful test 3.14 == 3.14 was successful test 1e-9d == 1.0e-9 was successful test 1e137 == 1.0e137 was successful +test 1.asInstanceOf[double] == 1.0 was successful +test 1l.asInstanceOf[double] == 1.0 was successful diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 4382f3730f..58b1c78ded 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -26,9 +26,71 @@ object Test { } def main(args: Array[String]) = { + // char + check_success("'\\u0024' == '$'", '\u0024', '$'); + check_success("'\\u005f' == '_'", '\u005f', '_'); + check_success("65.asInstanceOf[char] == 'A'", 65.asInstanceOf[char], 'A'); + + System.out.println(); + + // int + check_success("01 == 1", 01, 1); + check_success("010 == 8", 010, 8); + check_success("0X01 == 1", 0X01, 1); + check_success("0x01 == 1", 0x01, 1); + check_success("0x10 == 16", 0x10, 16); + check_success("0xa == 10", 0xa, 10); + check_success("0x0a == 10", 0x0a, 10); + + check_success("+01 == 1", +01, 1); + check_success("+010 == 8", +010, 8); + check_success("+0x01 == 1", +0x01, 1); + check_success("+0x10 == 16", +0x10, 16); + check_success("+0xa == 10", +0xa, 10); + check_success("+0x0a == 10", +0x0a, 10); + + check_success("-01 == -1", -01, -1); + check_success("-010 == -8", -010, -8); + check_success("-0x01 == -1", -0x01, -1); + check_success("-0x10 == -16", -0x10, -16); + check_success("-0xa == -10", -0xa, -10); + check_success("-0x0a == -10", -0x0a, -10); + + check_success("017777777777 == 2147483647", 017777777777, 2147483647); + check_success("020000000000 == -2147483648", 020000000000, -2147483647 -1); + check_success("037777777777 == -1", 037777777777, -1); + + check_success("0x7fffffff == 2147483647", 0x7fffffff, 2147483647); + check_success("0x80000000 == -2147483648", 0x80000000, -2147483647 -1); + check_success("0xffffffff == -1", 0xffffffff, -1); + + System.out.println(); + + // long + check_success("1l == 1L", 1l, 1L); + check_success("1L == 1l", 1L, 1l); + check_success("1.asInstanceOf[long] == 1l", 1.asInstanceOf[long], 1l); + + check_success("0777777777777777777777L == 9223372036854775807L", + 0777777777777777777777L, 9223372036854775807L); + check_success("01000000000000000000000L == -9223372036854775808L", + 01000000000000000000000L, -9223372036854775807L -1L); + check_success("01777777777777777777777L == -1L", + 01777777777777777777777L, -1L); + + check_success("0x7fffffffffffffffL == 9223372036854775807L", + 0x7fffffffffffffffL, 9223372036854775807L); + check_success("0x8000000000000000L == -9223372036854775808L", + 0x8000000000000000L, -9223372036854775807L -1L); + check_success("0xffffffffffffffffL == -1L", + 0xffffffffffffffffL, -1L); + + System.out.println(); + // see JLS at address: // http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798 + // float check_success("1e1f == 10.0f", 1e1f, 10.0f); check_success("2.f == 2.0f", 2.f, 2.0f); check_success(".3f == 0.3f", .3f, 0.3f); @@ -36,7 +98,12 @@ object Test { check_success("3.14f == 3.14f", 3.14f, 3.14f); check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f); check_success("09f == 9.0f", 09f, 9.0f); + check_success("1.asInstanceOf[float] == 1.0", 1.asInstanceOf[float], 1.0f); + check_success("1l.asInstanceOf[float] == 1.0", 1l.asInstanceOf[float], 1.0f); + + System.out.println(); + // double check_success("1e1 == 10.0", 1e1, 10.0); check_success("2. == 2.0", 2., 2.0); check_success("2.d == 2.0", 2.d, 2.0); @@ -46,6 +113,8 @@ object Test { check_success("3.14 == 3.14", 3.14, 3.14); check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9); check_success("1e137 == 1.0e137", 1e137, 1.0e137); + check_success("1.asInstanceOf[double] == 1.0", 1.asInstanceOf[double], 1.0); + check_success("1l.asInstanceOf[double] == 1.0", 1l.asInstanceOf[double], 1.0); } } |