From ba2913bdb52bf1a42bd831e9429e044ee8d3c42f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 29 Apr 2014 17:14:27 +0200 Subject: Changes to test framework and tests defaultOptions is now an implicit parameter, which means it can be overridden on a call-by-call basis. Added -Ycheck:front to verify that typed trees typecheck again with same types. The option is disabled for one of the structural tests. --- test/dotc/comptest.scala | 2 +- test/dotc/tests.scala | 16 +++++++++++----- test/test/CompilerTest.scala | 16 +++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/test/dotc/comptest.scala b/test/dotc/comptest.scala index e7f60488b..63c400304 100644 --- a/test/dotc/comptest.scala +++ b/test/dotc/comptest.scala @@ -15,7 +15,7 @@ object comptest extends CompilerTest { dotcDir + "tools/dotc/ast/Trees.scala", "#runs", "2", "-Ylog:frontend", - "-Xprompt")) + "-Xprompt"))(Nil) // compileDir(dotcDir + "tools/dotc/printing", List("-Xprompt", "-Ylog:frontend", "#runs", "2", "-uniqid")) } diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 4234a6541..436ca876f 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -5,15 +5,18 @@ import test._ class tests extends CompilerTest { - override val defaultOptions = - List( + val noCheckOptions = List( // "-verbose", // "-Ylog:frontend", // "-Xprompt", // "-explaintypes", // "-Yshow-suppressed-errors", - "-pagewidth", "160" //, "-Ycheck:front" , "-Ystop-before:terminal" - ) + "-pagewidth", "160") + + implicit val defaultOptions = noCheckOptions ++ List( + "-Ycheck:front"//, "-Ystop-before:terminal" + ) + val twice = List("#runs", "2", "-YnoDoubleBindings") val doErase = List("-Ystop-before:terminal") @@ -68,7 +71,10 @@ class tests extends CompilerTest { @Test def neg_i50_volatile = compileFile(negDir, "i50-volatile", xerrors = 4) @Test def neg_t0273_doubledefs = compileFile(negDir, "t0273", xerrors = 1) @Test def neg_t0586_structural = compileFile(negDir, "t0586", xerrors = 1) - @Test def neg_t0625_structural = compileFile(negDir, "t0625", xerrors = 1) + @Test def neg_t0625_structural = compileFile(negDir, "t0625", xerrors = 1)( + defaultOptions = noCheckOptions) + // -Ycheck fails because there are structural types involving higher-kinded types. + // these are illegal, but are tested only later. @Test def neg_t0654_polyalias = compileFile(negDir, "t0654", xerrors = 2) @Test def neg_t1192_legalPrefix = compileFile(negDir, "t1192", xerrors = 1) @Test def neg_tailcall_t1672b = compileFile(negDir, "tailcall/t1672b", xerrors = 6) diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala index d52e74de7..1bf138d54 100644 --- a/test/test/CompilerTest.scala +++ b/test/test/CompilerTest.scala @@ -8,29 +8,27 @@ import dotty.tools.dotc.reporting.Reporter class CompilerTest extends DottyTest { - def defaultOptions: List[String] = Nil - - def compileArgs(args: Array[String], xerrors: Int = 0): Unit = { + def compileArgs(args: Array[String], xerrors: Int = 0)(implicit defaultOptions: List[String]): Unit = { val allArgs = args ++ defaultOptions val processor = if (allArgs.exists(_.startsWith("#"))) Bench else Main val nerrors = processor.process(allArgs, ctx).count(Reporter.ERROR.level) assert(nerrors == xerrors, s"Wrong # of errors. Expected: $xerrors, found: $nerrors") } - def compileLine(cmdLine: String, xerrors: Int = 0): Unit = compileArgs(cmdLine.split("\n"), xerrors) + def compileLine(cmdLine: String, xerrors: Int = 0)(implicit defaultOptions: List[String]): Unit = compileArgs(cmdLine.split("\n"), xerrors) - def compileFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0): Unit = + def compileFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0)(implicit defaultOptions: List[String]): Unit = compileArgs((s"$prefix$fileName.scala" :: args).toArray, xerrors) - def compileDir(path: String, args: List[String] = Nil, xerrors: Int = 0): Unit = + def compileDir(path: String, args: List[String] = Nil, xerrors: Int = 0)(implicit defaultOptions: List[String]): Unit = compileDir(Directory(path), args, xerrors) - def compileDir(dir: Directory, args: List[String], xerrors: Int): Unit = { + def compileDir(dir: Directory, args: List[String], xerrors: Int)(implicit defaultOptions: List[String]): Unit = { val fileNames = dir.files.toArray.map(_.toString).filter(_ endsWith ".scala") compileArgs(fileNames ++ args, xerrors) } - def compileFiles(path: String, args: List[String] = Nil): Unit = { + def compileFiles(path: String, args: List[String] = Nil)(implicit defaultOptions: List[String]): Unit = { val dir = Directory(path) val fileNames = dir.files.toArray.map(_.toString).filter(_ endsWith ".scala") for (name <- fileNames) { @@ -43,7 +41,7 @@ class CompilerTest extends DottyTest { } } } -object CompilerText extends App { +object CompilerTest extends App { // val dotcDir = "/Users/odersky/workspace/dotty/src/dotty/" -- cgit v1.2.3