aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-08 18:08:22 +0100
committerMartin Odersky <odersky@gmail.com>2016-03-12 16:08:38 +0100
commit87b30c986be145806591c16445ec90a8a54dcee0 (patch)
treeba5abb57d27082b811434e05e4bab5a25cb28253 /test
parent919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f (diff)
downloaddotty-87b30c986be145806591c16445ec90a8a54dcee0.tar.gz
dotty-87b30c986be145806591c16445ec90a8a54dcee0.tar.bz2
dotty-87b30c986be145806591c16445ec90a8a54dcee0.zip
Rewrite test
Test rewritings that were implemented so far.
Diffstat (limited to 'test')
-rw-r--r--test/dotc/tests.scala2
-rw-r--r--test/test/CompilerTest.scala18
2 files changed, 19 insertions, 1 deletions
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 2d4ed289c..457116feb 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -104,6 +104,8 @@ class tests extends CompilerTest {
@Test def pos_scala2_all = compileFiles(posScala2Dir, scala2mode)
+ @Test def rewrites = compileFile(posScala2Dir, "rewrites", "-rewrite" :: scala2mode)
+
@Test def pos_859 = compileFile(posSpecialDir, "i859", scala2mode)(allowDeepSubtypes)
@Test def new_all = compileFiles(newDir, twice)
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