summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-08-22 14:55:08 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-09-02 11:30:21 +0200
commitb562d965dc30bb1fdd9433a6675bfe8e38b8c667 (patch)
tree3bc0dcdc6608d939d6b67fd35a2b2d16930c6ce6 /test
parent0a6dd09d7585448d0c66835a2d2618eb12a47786 (diff)
downloadscala-b562d965dc30bb1fdd9433a6675bfe8e38b8c667.tar.gz
scala-b562d965dc30bb1fdd9433a6675bfe8e38b8c667.tar.bz2
scala-b562d965dc30bb1fdd9433a6675bfe8e38b8c667.zip
-Ystatistics accepts a list of phases, cleanups in MultiChoiceSetting
MultiChoiceSetting and Xlint with its deprecated aliases is now a bit simpler, but there's still room for improvement, as noted in comments.
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/tools/nsc/settings/SettingsTest.scala63
1 files changed, 62 insertions, 1 deletions
diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
index 960d7f8ac1..a0e015be32 100644
--- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala
+++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
@@ -39,7 +39,7 @@ class SettingsTest {
}
// for the given args, select the desired setting
- private def check(args: String*)(b: MutableSettings => MutableSettings#BooleanSetting): MutableSettings#BooleanSetting = {
+ private def check(args: String*)(b: MutableSettings => Boolean): Boolean = {
val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))
val (ok, residual) = s.processArguments(args.toList, processAll = true)
assert(residual.isEmpty)
@@ -54,7 +54,68 @@ class SettingsTest {
@Test def anonymousLintersCanBeNamed() {
assertTrue(check("-Xlint")(_.warnMissingInterpolator)) // among Xlint
assertFalse(check("-Xlint:-missing-interpolator")(_.warnMissingInterpolator))
+
+ // positive overrides negative, but not the other way around
+ assertTrue(check("-Xlint:-missing-interpolator,missing-interpolator")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:-missing-interpolator", "-Xlint:missing-interpolator")(_.warnMissingInterpolator))
+
+ assertTrue(check("-Xlint:missing-interpolator,-missing-interpolator")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:missing-interpolator", "-Xlint:-missing-interpolator")(_.warnMissingInterpolator))
+
+ // -Xlint:_ adds all possible choices, but explicit negative settings will override
+ assertFalse(check("-Xlint:-missing-interpolator,_")(_.warnMissingInterpolator))
+ assertFalse(check("-Xlint:-missing-interpolator", "-Xlint:_")(_.warnMissingInterpolator))
+ assertFalse(check("-Xlint:_", "-Xlint:-missing-interpolator")(_.warnMissingInterpolator))
+ assertFalse(check("-Xlint:_,-missing-interpolator")(_.warnMissingInterpolator))
+
+ // -Xlint is the same as -Xlint:_
assertFalse(check("-Xlint:-missing-interpolator", "-Xlint")(_.warnMissingInterpolator))
assertFalse(check("-Xlint", "-Xlint:-missing-interpolator")(_.warnMissingInterpolator))
+
+ // combination of positive, negative and _
+ assertTrue(check("-Xlint:_,-missing-interpolator,missing-interpolator")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:-missing-interpolator,_,missing-interpolator")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:-missing-interpolator,missing-interpolator,_")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:missing-interpolator,-missing-interpolator,_")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint:missing-interpolator,_,-missing-interpolator")(_.warnMissingInterpolator))
+ }
+
+ @Test def xLintInvalidChoices(): Unit = {
+ assertThrows[IllegalArgumentException](check("-Xlint:-_")(_.warnAdaptedArgs))
+ assertThrows[IllegalArgumentException](check("-Xlint:-warn-adapted-args")(_.warnAdaptedArgs)) // "warn-" should not be there
+ }
+
+ @Test def xLintNonColonated(): Unit = {
+ assertTrue(check("-Xlint", "adapted-args", "-deprecation")(_.warnAdaptedArgs))
+ assertFalse(check("-Xlint", "adapted-args", "-deprecation")(_.warnMissingInterpolator))
+ assertTrue(check("-Xlint", "adapted-args", "missing-interpolator", "-deprecation")(s => s.warnMissingInterpolator && s.warnAdaptedArgs))
+ assertThrows[IllegalArgumentException](check("-Xlint", "adapted-args", "-missing-interpolator")(_.warnAdaptedArgs)) // non-colonated: cannot provide negative args
+ }
+
+ @Test def xLintContainsValues(): Unit = {
+ // make sure that lint.contains and lint.value.contains are consistent
+ def t(s: MutableSettings, v: String) = {
+ val r = s.lint.contains(v)
+ assertSame(r, s.lint.value.contains(v))
+ r
+ }
+
+ assertTrue(check("-Xlint")(t(_, "adapted-args")))
+ assertTrue(check("-Xlint:_")(t(_, "adapted-args")))
+ assertFalse(check("-Xlint:_,-adapted-args")(t(_, "adapted-args")))
+ assertFalse(check("-Xlint:-adapted-args,_")(t(_, "adapted-args")))
+ assertTrue(check("-Xlint:-adapted-args,_,adapted-args")(t(_, "adapted-args")))
+ }
+
+ @Test def xLintDeprecatedAlias(): Unit = {
+ assertTrue(check("-Ywarn-adapted-args")(_.warnAdaptedArgs))
+ assertTrue(check("-Xlint:_,-adapted-args", "-Ywarn-adapted-args")(_.warnAdaptedArgs))
+ assertTrue(check("-Xlint:-adapted-args", "-Ywarn-adapted-args")(_.warnAdaptedArgs))
+ assertTrue(check("-Ywarn-adapted-args", "-Xlint:-adapted-args,_")(_.warnAdaptedArgs))
+
+ assertFalse(check("-Ywarn-adapted-args:false")(_.warnAdaptedArgs))
+ assertFalse(check("-Ywarn-adapted-args:false", "-Xlint:_")(_.warnAdaptedArgs))
+ assertFalse(check("-Ywarn-adapted-args:false", "-Xlint:_,-adapted-args")(_.warnAdaptedArgs))
+ assertTrue(check("-Ywarn-adapted-args:false", "-Xlint:_,adapted-args")(_.warnAdaptedArgs))
}
}