summaryrefslogtreecommitdiff
path: root/test/files/neg/stringinterpolation_macro-neg.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-06 14:05:44 +0200
committerDominik Gruntz <dominik.gruntz@fhnw.ch>2012-07-06 14:54:21 +0200
commit58c053c454dd0cb1146434b97380e4910b6060d7 (patch)
tree5bee38c8f6d60c87950f147ab23b7f74f7357b98 /test/files/neg/stringinterpolation_macro-neg.scala
parent70f493dc438f464c865e5deb38b46e4e0e773486 (diff)
downloadscala-58c053c454dd0cb1146434b97380e4910b6060d7.tar.gz
scala-58c053c454dd0cb1146434b97380e4910b6060d7.tar.bz2
scala-58c053c454dd0cb1146434b97380e4910b6060d7.zip
stringinterpolation macro test files
This commit adds test files neg: checks the error messages generated by the compiler run: checks the macro implementation features
Diffstat (limited to 'test/files/neg/stringinterpolation_macro-neg.scala')
-rw-r--r--test/files/neg/stringinterpolation_macro-neg.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/files/neg/stringinterpolation_macro-neg.scala b/test/files/neg/stringinterpolation_macro-neg.scala
new file mode 100644
index 0000000000..ac9d97d678
--- /dev/null
+++ b/test/files/neg/stringinterpolation_macro-neg.scala
@@ -0,0 +1,31 @@
+object Test extends App {
+ val s = "Scala"
+ val d = 8
+ val b = false
+ val f = 3.14159
+
+ // 1) number of arguments
+ new StringContext().f()
+ new StringContext("", " is ", "%2d years old").f(s)
+ new StringContext("", " is ", "%2d years old").f(s, d, d)
+ new StringContext("", "").f()
+
+ // 2) Interpolation mismatches
+ f"$s%b"
+ f"$s%c"
+ f"$f%c"
+ f"$s%x"
+ f"$b%d"
+ f"$s%d"
+ f"$f%o"
+ f"$s%e"
+ f"$b%f"
+
+ {
+ implicit val strToInt1 = (s: String) => 1
+ implicit val strToInt2 = (s: String) => 2
+ f"$s%d"
+ }
+
+ f"$s%i"
+}