From 76caa37f22b70b126563df8a5eeab1b8bf693fc9 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Tue, 17 Jan 2012 17:26:59 -0200 Subject: Fix check for number of arguments Fix the test for number of arguments by passing all arguments instead of passing the argument list as a single argument. Add positive and negative tests for it. --- test/files/run/interpolation.check | 6 ++++++ test/files/run/interpolation.scala | 2 ++ test/files/run/interpolationArgs.check | 2 ++ test/files/run/interpolationArgs.flags | 1 + test/files/run/interpolationArgs.scala | 5 +++++ 5 files changed, 16 insertions(+) create mode 100644 test/files/run/interpolationArgs.check create mode 100644 test/files/run/interpolationArgs.flags create mode 100644 test/files/run/interpolationArgs.scala (limited to 'test') diff --git a/test/files/run/interpolation.check b/test/files/run/interpolation.check index 4c34e4c8c8..09579a800a 100644 --- a/test/files/run/interpolation.check +++ b/test/files/run/interpolation.check @@ -2,14 +2,20 @@ Bob is 1 years old Bob is 1 years old Bob will be 2 years old Bob will be 2 years old +1+1 = 2 +1+1 = 2 Bob is 12 years old Bob is 12 years old Bob will be 13 years old Bob will be 13 years old +12+1 = 13 +12+1 = 13 Bob is 123 years old Bob is 123 years old Bob will be 124 years old Bob will be 124 years old +123+1 = 124 +123+1 = 124 Best price: 10.0 Best price: 10.00 10.0% discount included diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala index 232a180bcd..a0a185eaab 100644 --- a/test/files/run/interpolation.scala +++ b/test/files/run/interpolation.scala @@ -5,6 +5,8 @@ object Test extends App { println(f"Bob is $n%2d years old") println(s"Bob will be ${n+1} years old") println(f"Bob will be ${n+1}%2d years old") + println(s"$n+1 = ${n+1}") + println(f"$n%d+1 = ${n+1}%d") } def test2(f: Float) = { diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check new file mode 100644 index 0000000000..155991e618 --- /dev/null +++ b/test/files/run/interpolationArgs.check @@ -0,0 +1,2 @@ +java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments for interpolated string diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/interpolationArgs.flags @@ -0,0 +1 @@ +-Xexperimental \ No newline at end of file diff --git a/test/files/run/interpolationArgs.scala b/test/files/run/interpolationArgs.scala new file mode 100644 index 0000000000..eb13767907 --- /dev/null +++ b/test/files/run/interpolationArgs.scala @@ -0,0 +1,5 @@ +object Test extends App { + try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex => println(ex) } + try { scala.StringContext("p1").s("e1") } catch { case ex => println(ex) } +} + -- cgit v1.2.3