From a40af3e42fdfff62901dbc807ed3d899272d2b37 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 28 Feb 2014 05:25:08 -0800 Subject: 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. --- test/files/run/t5905-features.flags | 1 + test/files/run/t5905-features.scala | 28 ++++++++++++++++++++++++++++ test/files/run/t5905b-features.check | 1 + test/files/run/t5905b-features.scala | 15 +++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 test/files/run/t5905-features.flags create mode 100644 test/files/run/t5905-features.scala create mode 100644 test/files/run/t5905b-features.check create mode 100644 test/files/run/t5905b-features.scala (limited to 'test/files/run') 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") + } +} + -- cgit v1.2.3