summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-02-28 05:25:08 -0800
committerSom Snytt <som.snytt@gmail.com>2014-02-28 09:04:42 -0800
commita40af3e42fdfff62901dbc807ed3d899272d2b37 (patch)
tree528339320e7b7c5c9fc43883ecc9713e93a2ee19 /test/files/run
parentec4479aa7d0279daa701481fb7d77c1f43617190 (diff)
downloadscala-a40af3e42fdfff62901dbc807ed3d899272d2b37.tar.gz
scala-a40af3e42fdfff62901dbc807ed3d899272d2b37.tar.bz2
scala-a40af3e42fdfff62901dbc807ed3d899272d2b37.zip
SI-5905 Sanity check -language options
The option names are hardcoded, but checked by a test. There are no hooks to verify options after the compiler is constructed. Introduced a `MultiChoiceSetting` required for the setting creation framework.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t5905-features.flags1
-rw-r--r--test/files/run/t5905-features.scala28
-rw-r--r--test/files/run/t5905b-features.check1
-rw-r--r--test/files/run/t5905b-features.scala15
4 files changed, 45 insertions, 0 deletions
diff --git a/test/files/run/t5905-features.flags b/test/files/run/t5905-features.flags
new file mode 100644
index 0000000000..ad51758c39
--- /dev/null
+++ b/test/files/run/t5905-features.flags
@@ -0,0 +1 @@
+-nowarn
diff --git a/test/files/run/t5905-features.scala b/test/files/run/t5905-features.scala
new file mode 100644
index 0000000000..fbffddf114
--- /dev/null
+++ b/test/files/run/t5905-features.scala
@@ -0,0 +1,28 @@
+
+import tools.partest.DirectTest
+
+// verify that all languageFeature names are accepted by -language
+object Test extends DirectTest {
+ override def code = "class Code { def f = (1 to 10) size }" // exercise a feature
+
+ override def extraSettings = s"-usejavacp -d ${testOutput.path}"
+
+ override def show() = {
+ val global = newCompiler("-language:postfixOps", "-Ystop-after:typer")
+ compileString(global)(code)
+ import global._
+ exitingTyper {
+ def isFeature(s: Symbol) = s.annotations.exists((a: AnnotationInfo) => a.tpe <:< typeOf[scala.annotation.meta.languageFeature])
+ val langf = definitions.languageFeatureModule.typeSignature
+ val feats = langf.declarations filter (s => isFeature(s)) map (_.name.decoded)
+ val xmen = langf.member(TermName("experimental")).typeSignature.declarations filter (s => isFeature(s)) map (s => s"experimental.${s.name.decoded}")
+ val all = (feats ++ xmen) mkString ","
+
+ assert(feats.nonEmpty, "Test must find feature flags.")
+
+ //dynamics,postfixOps,reflectiveCalls,implicitConversions,higherKinds,existentials,experimental.macros
+ compile(s"-language:$all")
+ }
+ }
+}
+
diff --git a/test/files/run/t5905b-features.check b/test/files/run/t5905b-features.check
new file mode 100644
index 0000000000..08c76d74aa
--- /dev/null
+++ b/test/files/run/t5905b-features.check
@@ -0,0 +1 @@
+'noob' is not a valid choice for '-language'
diff --git a/test/files/run/t5905b-features.scala b/test/files/run/t5905b-features.scala
new file mode 100644
index 0000000000..627df8334b
--- /dev/null
+++ b/test/files/run/t5905b-features.scala
@@ -0,0 +1,15 @@
+
+import tools.partest.DirectTest
+
+// verify that only languageFeature names are accepted by -language
+object Test extends DirectTest {
+ override def code = "class Code"
+
+ override def extraSettings = s"-usejavacp -d ${testOutput.path}"
+
+ override def show() = {
+ //compile("-language", "--") // no error
+ compile(s"-language:noob")
+ }
+}
+