From 55549bfa41f4a19c9556b71791de35875e8229dc Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 17 Feb 2014 18:26:12 +0100 Subject: Expose a means to disable boolean settings Enables `-Yboolean-setting:{true,false}`. This will be exploited in the next commit to enable one to turn off a single component of a group setting, such as `-Xlint` or `-optimize`. --- .../scala/tools/nsc/settings/SettingsTest.scala | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/junit/scala/tools/nsc/settings/SettingsTest.scala (limited to 'test/junit') diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala new file mode 100644 index 0000000000..4b0e58ff79 --- /dev/null +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -0,0 +1,28 @@ +package scala.tools.nsc +package settings + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import scala.tools.testing.AssertUtil.assertThrows + +@RunWith(classOf[JUnit4]) +class SettingsTest { + @Test def booleanSettingColon() { + def check(args: String*): MutableSettings#BooleanSetting = { + val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) + val b1 = new s.BooleanSetting("-Ytest-setting", "") + s.allSettings += b1 + val (ok, residual) = s.processArguments(args.toList, processAll = true) + assert(residual.isEmpty) + b1 + } + assertTrue(check("-Ytest-setting").value) + assertTrue(check("-Ytest-setting:true").value) + assertTrue(check("-Ytest-setting:TRUE").value) + assertFalse(check("-Ytest-setting:false").value) + assertFalse(check("-Ytest-setting:FALSE").value) + assertThrows[IllegalArgumentException](check("-Ytest-setting:rubbish")) + } +} -- cgit v1.2.3