summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-08-19 11:48:50 +0200
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-08-19 11:48:50 +0200
commit5e0880fe05fb65a8757721be7e5be6a3259c19a8 (patch)
treefada590b863e805aa5ace25481e6a36255213b97 /test
parent7a6947487dc8ea551ff7489b07cc30366b39d25e (diff)
parent606a553e12dbc1bda25939dbda3e7fcaaaa678b9 (diff)
downloadscala-5e0880fe05fb65a8757721be7e5be6a3259c19a8.tar.gz
scala-5e0880fe05fb65a8757721be7e5be6a3259c19a8.tar.bz2
scala-5e0880fe05fb65a8757721be7e5be6a3259c19a8.zip
Merge pull request #3909 from som-snytt/issue/8512
SI-8512 Infer a type for f"$args"
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t7848-interp-warn.flags2
-rw-r--r--test/files/pos/t8013.flags2
-rw-r--r--test/junit/scala/StringContextTest.scala13
-rw-r--r--test/junit/scala/reflect/QTest.scala23
4 files changed, 38 insertions, 2 deletions
diff --git a/test/files/neg/t7848-interp-warn.flags b/test/files/neg/t7848-interp-warn.flags
index 7949c2afa2..b0d7bc25cb 100644
--- a/test/files/neg/t7848-interp-warn.flags
+++ b/test/files/neg/t7848-interp-warn.flags
@@ -1 +1 @@
--Xlint -Xfatal-warnings
+-Xlint:missing-interpolator -Xfatal-warnings
diff --git a/test/files/pos/t8013.flags b/test/files/pos/t8013.flags
index 954eaba352..3955bb6710 100644
--- a/test/files/pos/t8013.flags
+++ b/test/files/pos/t8013.flags
@@ -1 +1 @@
--Xfatal-warnings -Xlint
+-Xfatal-warnings -Xlint:-infer-any,_
diff --git a/test/junit/scala/StringContextTest.scala b/test/junit/scala/StringContextTest.scala
index bb0e8c4252..608b82bd96 100644
--- a/test/junit/scala/StringContextTest.scala
+++ b/test/junit/scala/StringContextTest.scala
@@ -62,4 +62,17 @@ class StringContextTest {
//assertEquals("????", s"????")
assertEquals("!!!!", s"????") // OK to hijack core interpolator ids
}
+
+ @Test def fIf() = {
+ val res = f"${if (true) 2.5 else 2.5}%.2f"
+ assertEquals("2.50", res)
+ }
+ @Test def fIfNot() = {
+ val res = f"${if (false) 2.5 else 3.5}%.2f"
+ assertEquals("3.50", res)
+ }
+ @Test def fHeteroArgs() = {
+ val res = f"${3.14}%.2f rounds to ${3}%d"
+ assertEquals("3.14 rounds to 3", res)
+ }
}
diff --git a/test/junit/scala/reflect/QTest.scala b/test/junit/scala/reflect/QTest.scala
new file mode 100644
index 0000000000..24c35dc401
--- /dev/null
+++ b/test/junit/scala/reflect/QTest.scala
@@ -0,0 +1,23 @@
+
+package scala.reflect
+
+import org.junit.Test
+import org.junit.Assert._
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.tools.testing.AssertUtil._
+
+@RunWith(classOf[JUnit4])
+class QTest {
+
+ import reflect.runtime._
+ import universe._
+ @Test def qConstantsNotHomogenized() = {
+ //Apply(Select(Literal(Constant(1.0)), TermName("$plus")), List(Literal(Constant(1.0))))
+ val t = q"${1} + ${1.0}"
+ val Apply(Select(Literal(Constant(i)), TermName("$plus")), List(Literal(Constant(j)))) = t
+ assertEquals(1, i)
+ assertEquals(1.0, j)
+ }
+}