diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-10 20:39:01 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-13 08:13:09 -0800 |
commit | 92daa5eda501b1b3a4368a42963af6df578906c4 (patch) | |
tree | cb0a3d684d6236846d583afccd2af9d99b4fe9a6 /test/files/run/settings-parse.scala | |
parent | 91abce5d1a5c5681dbac565cb4cbcf81ff54bb60 (diff) | |
download | scala-92daa5eda501b1b3a4368a42963af6df578906c4.tar.gz scala-92daa5eda501b1b3a4368a42963af6df578906c4.tar.bz2 scala-92daa5eda501b1b3a4368a42963af6df578906c4.zip |
Address obvious bug in MutableSettings.
If x startsWith "-" it seems unlikely that x == "".
Free with purchase: test case with 100 argument permutations.
That's only a smidgen shy of infinity.
Diffstat (limited to 'test/files/run/settings-parse.scala')
-rw-r--r-- | test/files/run/settings-parse.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala new file mode 100644 index 0000000000..2b04f55b24 --- /dev/null +++ b/test/files/run/settings-parse.scala @@ -0,0 +1,27 @@ +import scala.tools.nsc._ + +object Test { + val tokens = List("", "-deprecation", "foo.scala") + val subsets = tokens.toSet.subsets.toList + val permutations0 = subsets.flatMap(_.toList.permutations).distinct + + def runWithCp(cp: String) = { + val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) + + for ((p, i) <- permutations.distinct.sortBy(_ mkString "").zipWithIndex) { + val args = p flatMap (_ split "\\s+") map (x => if (x == "CPTOKEN") cp else x) + val s = new settings.MutableSettings(println) + val (ok, residual) = s.processArguments(args, processAll = true) + + val expected = args filter (_ == "foo.scala") + assert(residual == expected, residual) + assert(ok, args) + println(s"$i) $args ==> $s") + } + } + + def main(args0: Array[String]): Unit = { + runWithCp("") + runWithCp("/tmp:/bippy") + } +} |