diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-11-03 17:23:05 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-11-04 09:50:51 +0100 |
commit | 10c745ae976f8e488dcde66587d0741890112c13 (patch) | |
tree | a1719b9544985f9e40187443d01b2bbe1ffee378 /test/junit | |
parent | d1a76d5af7faa12ebebea0923812af26c40eebc9 (diff) | |
download | scala-10c745ae976f8e488dcde66587d0741890112c13.tar.gz scala-10c745ae976f8e488dcde66587d0741890112c13.tar.bz2 scala-10c745ae976f8e488dcde66587d0741890112c13.zip |
Fix default value for ScalaVersionSetting
The default value was NoScalaVersion before, because tryToSet (where
the default was supposed to be set) is not called at all if the option
is not specified.
The initial value of Xmigration is set to NoScalaVersion (which it was
before, the AnyScalaVersion argument was ignored). AnyScalaVersion
would be wrong, it would give a warning in `Map(1 -> "eis").values`
if the option was not specified. See tests.
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/tools/nsc/settings/SettingsTest.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index eda0c27834..96f83c4c2f 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -164,4 +164,20 @@ class SettingsTest { assertThrows[IllegalArgumentException](check("-m:a,b,-ab")(_ => true), _ contains "'ab' cannot be negated") assertThrows[IllegalArgumentException](check("-m:a,ac,-uber,uber")(_ => true), _ contains "'uber' cannot be negated") } + + @Test def xSourceTest(): Unit = { + def check(expected: String, args: String*): Unit = { + val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) + val (_, residual) = s.processArguments(args.toList, processAll = true) + assert(residual.isEmpty) + assertTrue(s.source.value == ScalaVersion(expected)) + } + check(expected = "2.11.0") // default + check(expected = "2.11.0", "-Xsource:2.11") + check(expected = "2.10", "-Xsource:2.10.0") + check(expected = "2.12", "-Xsource:2.12") + assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>") + assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource", "2.11"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>") + assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "There was a problem parsing 2.invalid") + } } |