diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-08 18:08:22 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-12 16:08:38 +0100 |
commit | 87b30c986be145806591c16445ec90a8a54dcee0 (patch) | |
tree | ba5abb57d27082b811434e05e4bab5a25cb28253 /test/test/CompilerTest.scala | |
parent | 919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f (diff) | |
download | dotty-87b30c986be145806591c16445ec90a8a54dcee0.tar.gz dotty-87b30c986be145806591c16445ec90a8a54dcee0.tar.bz2 dotty-87b30c986be145806591c16445ec90a8a54dcee0.zip |
Rewrite test
Test rewritings that were implemented so far.
Diffstat (limited to 'test/test/CompilerTest.scala')
-rw-r--r-- | test/test/CompilerTest.scala | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala index 678ef74b1..739bba46d 100644 --- a/test/test/CompilerTest.scala +++ b/test/test/CompilerTest.scala @@ -10,6 +10,7 @@ import scala.reflect.io.{ Path, Directory, File => SFile, AbstractFile } import scala.tools.partest.nest.{ FileManager, NestUI } import scala.annotation.tailrec import java.io.{ RandomAccessFile, File => JFile } +import dotty.tools.io.PlainFile import org.junit.Test @@ -89,7 +90,20 @@ abstract class CompilerTest { if (!generatePartestFiles || !partestableFile(prefix, fileName, extension, args ++ defaultOptions)) { if (runTest) log(s"WARNING: run tests can only be run by partest, JUnit just verifies compilation: $prefix$fileName$extension") - compileArgs((s"$filePath" :: args).toArray, expErrors) + if (args.contains("-rewrite")) { + val file = new PlainFile(filePath) + val data = file.toByteArray + val cs = data.map(_.toChar) + println(s"data = ${cs.mkString}") + compileArgs((filePath :: args).toArray, expErrors) + val plainArgs = args.filter(arg => arg != "-rewrite" && arg != "-language:Scala2") + println(s"plainArgs = $plainArgs") + compileFile(prefix, fileName, plainArgs, extension, runTest) + val out = file.output + out.write(data) + out.close() + } + else compileArgs((filePath :: args).toArray, expErrors) } else { val kind = testKind(prefix, runTest) log(s"generating partest files for test file: $prefix$fileName$extension of kind $kind") @@ -191,6 +205,8 @@ abstract class CompilerTest { } } + + // ========== HELPERS ============= private def expectedErrors(filePaths: List[String]): List[ErrorsInFile] = if (filePaths.exists(isNegTest(_))) filePaths.map(getErrors(_)) else Nil |