diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/interpolation.check | 20 | ||||
-rw-r--r-- | test/files/run/interpolation.flags (renamed from test/files/run/stringInterpolation.flags) | 0 | ||||
-rw-r--r-- | test/files/run/interpolation.scala | 24 | ||||
-rw-r--r-- | test/files/run/stringInterpolation.check | 2 | ||||
-rw-r--r-- | test/files/run/stringInterpolation.scala | 7 |
5 files changed, 44 insertions, 9 deletions
diff --git a/test/files/run/interpolation.check b/test/files/run/interpolation.check new file mode 100644 index 0000000000..4c34e4c8c8 --- /dev/null +++ b/test/files/run/interpolation.check @@ -0,0 +1,20 @@ +Bob is 1 years old +Bob is 1 years old +Bob will be 2 years old +Bob will be 2 years old +Bob is 12 years old +Bob is 12 years old +Bob will be 13 years old +Bob will be 13 years old +Bob is 123 years old +Bob is 123 years old +Bob will be 124 years old +Bob will be 124 years old +Best price: 10.0 +Best price: 10.00 +10.0% discount included +10.00% discount included +Best price: 13.345 +Best price: 13.35 +13.345% discount included +13.35% discount included diff --git a/test/files/run/stringInterpolation.flags b/test/files/run/interpolation.flags index 48fd867160..48fd867160 100644 --- a/test/files/run/stringInterpolation.flags +++ b/test/files/run/interpolation.flags diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala new file mode 100644 index 0000000000..232a180bcd --- /dev/null +++ b/test/files/run/interpolation.scala @@ -0,0 +1,24 @@ +object Test extends App { + + def test1(n: Int) = { + println(s"Bob is $n years old") + 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") + } + + def test2(f: Float) = { + println(s"Best price: $f") + println(f"Best price: $f%.2f") + println(s"$f% discount included") + println(f"$f%3.2f% discount included") + } + + test1(1) + test1(12) + test1(123) + + test2(10.0f) + test2(13.345f) + +} diff --git a/test/files/run/stringInterpolation.check b/test/files/run/stringInterpolation.check deleted file mode 100644 index b5b63343a8..0000000000 --- a/test/files/run/stringInterpolation.check +++ /dev/null @@ -1,2 +0,0 @@ -1 plus 1 is 2 -We have a 1.10% chance of success diff --git a/test/files/run/stringInterpolation.scala b/test/files/run/stringInterpolation.scala deleted file mode 100644 index d88f5f6889..0000000000 --- a/test/files/run/stringInterpolation.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def main(args : Array[String]) : Unit = { - println("\{1} plus \{1} is \{1 + 1}") - val x = 1.1 - println("We have a \{ x ;2.2f}% chance of success") - } -} |