From 0538e7fd086c39226b2d005865eee07bb83f5b2e Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 17 Feb 2014 18:54:46 +0100 Subject: Group settings should honor user-set individual options In the last commit, we added the ability to explicitly disable boolean settings form the command line. This commit changes group settings (like -optimize), to leave them alone if set explicitly. Examples: `scalac -Xlint -Ywarn-unused:false -optimize -Yinline:false` The mechanism for such settings has also been refactored to `MutableSettings`, to let use reuse this for `-Xlint`. --- .../scala/tools/nsc/settings/SettingsTest.scala | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/junit') diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index 4b0e58ff79..e4b5ecc7c3 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -25,4 +25,28 @@ class SettingsTest { assertFalse(check("-Ytest-setting:FALSE").value) assertThrows[IllegalArgumentException](check("-Ytest-setting:rubbish")) } + + @Test def userSettingsHavePredecenceOverOptimize() { + def check(args: String*): MutableSettings#BooleanSetting = { + val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) + val (ok, residual) = s.processArguments(args.toList, processAll = true) + assert(residual.isEmpty) + s.inline // among -optimize + } + assertTrue(check("-optimise").value) + assertFalse(check("-optimise", "-Yinline:false").value) + assertFalse(check("-Yinline:false", "-optimise").value) + } + + @Test def userSettingsHavePredecenceOverLint() { + def check(args: String*): MutableSettings#BooleanSetting = { + val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) + val (ok, residual) = s.processArguments(args.toList, processAll = true) + assert(residual.isEmpty) + s.warnAdaptedArgs // among Xlint + } + assertTrue(check("-Xlint").value) + assertFalse(check("-Xlint", "-Ywarn-adapted-args:false").value) + assertFalse(check("-Ywarn-adapted-args:false", "-Xlint").value) + } } -- cgit v1.2.3