aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartijn Hoekstra <Martijn Hoekstra>2016-09-03 12:10:53 +0200
committerMartijn Hoekstra <Martijn Hoekstra>2016-09-07 22:32:51 +0200
commit32819e2edc88dd06095704c04ed9c2dd0603386f (patch)
tree5ac33b7a4fc11fe5b13aeae26e963e5553e97fad /test
parent6bce106fea7ce10eefc864a6e7c1351675065880 (diff)
downloaddotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.gz
dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.bz2
dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.zip
honor -encoding compiler flag and defaults
rename test/pos/valueclasses to pos_valueclasses tests/pos/valueclasses generates a valueclasses.flags file in /tests/partest-generated/pos that conflicts with the valueClasses.flags file that tests/neg/valueClasses.scala tries to create
Diffstat (limited to 'test')
-rw-r--r--test/dotc/tests.scala10
-rw-r--r--test/test/CompilerTest.scala8
-rw-r--r--test/test/DottyTest.scala1
-rw-r--r--test/test/ParserTest.scala3
-rw-r--r--test/test/ScannerTest.scala5
5 files changed, 18 insertions, 9 deletions
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 9f95a30c1..c4d8085f5 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -23,8 +23,7 @@ class tests extends CompilerTest {
val defaultOutputDir = "./out/"
implicit val defaultOptions = noCheckOptions ++ List(
- "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases",
- "-d", defaultOutputDir) ++ {
+ "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-d", defaultOutputDir) ++ {
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
}
@@ -38,6 +37,9 @@ class tests extends CompilerTest {
val allowDoubleBindings = defaultOptions diff List("-Yno-double-bindings")
val scala2mode = List("-language:Scala2")
+ val explicitUTF8 = List("-encoding", "UTF8")
+ val explicitUTF16 = List("-encoding", "UTF16")
+
val testsDir = "./tests/"
val posDir = testsDir + "pos/"
val posSpecialDir = testsDir + "pos-special/"
@@ -95,7 +97,7 @@ class tests extends CompilerTest {
@Test def pos_overloadedAccess = compileFile(posDir, "overloadedAccess", twice)
@Test def pos_approximateUnion = compileFile(posDir, "approximateUnion", twice)
@Test def pos_tailcall = compileDir(posDir, "tailcall", twice)
- @Test def pos_valueclasses = compileFiles(posDir + "valueclasses/", twice)
+ @Test def pos_valueclasses = compileFiles(posDir + "pos_valueclasses/", twice)
@Test def pos_nullarify = compileFile(posDir, "nullarify", args = "-Ycheck:nullarify" :: Nil)
@Test def pos_subtyping = compileFile(posDir, "subtyping", twice)
@Test def pos_packageObj = compileFile(posDir, "i0239", twice)
@@ -118,6 +120,8 @@ class tests extends CompilerTest {
compileFile(posSpecialDir, "spec-t5545/S_1")
compileFile(posSpecialDir, "spec-t5545/S_2")
}
+ @Test def pos_utf8 = compileFile(posSpecialDir, "utf8encoded", explicitUTF8)
+ @Test def pos_utf16 = compileFile(posSpecialDir, "utf16encoded", explicitUTF16)
@Test def new_all = compileFiles(newDir, twice)
@Test def repl_all = replFiles(replDir)
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala
index d0e4b9a52..6bd5f7030 100644
--- a/test/test/CompilerTest.scala
+++ b/test/test/CompilerTest.scala
@@ -413,7 +413,8 @@ abstract class CompilerTest {
val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f) ++
List(s"-classpath $partestOutput") // Required for separate compilation tests
- getExisting(dest).isDifferent(source, flags, nerr) match {
+ val difference = getExisting(dest).isDifferent(source, flags, nerr)
+ difference match {
case NotExists => copyFiles(source, dest, partestOutput, flags, nerr, kind)
case ExistsSame => // nothing else to do
case ExistsDifferent =>
@@ -449,6 +450,7 @@ abstract class CompilerTest {
/** Recursively copy over source files and directories, excluding extensions
* that aren't in extensionsToCopy. */
private def recCopyFiles(sourceFile: Path, dest: Path): Unit = {
+
def copyfile(file: SFile, bytewise: Boolean): Unit = {
if (bytewise) {
val in = file.inputStream()
@@ -490,7 +492,7 @@ abstract class CompilerTest {
/** Reads the existing files for the given test source if any. */
private def getExisting(dest: Path): ExistingFiles = {
- val content: Option[Option[String]] = processFileDir(dest, f => f.safeSlurp, d => Some(""))
+ val content: Option[Option[String]] = processFileDir(dest, f => try Some(f.slurp("UTF8")) catch {case io: java.io.IOException => Some(io.toString())}, d => Some(""))
if (content.isDefined && content.get.isDefined) {
val flags = (dest changeExtension "flags").toFile.safeSlurp
val nerr = (dest changeExtension "nerr").toFile.safeSlurp
@@ -504,7 +506,7 @@ abstract class CompilerTest {
if (!genSrc.isDefined) {
NotExists
} else {
- val source = processFileDir(sourceFile, { f => f.safeSlurp }, { d => Some("") },
+ val source = processFileDir(sourceFile, { f => try Some(f.slurp("UTF8")) catch {case _: java.io.IOException => None} }, { d => Some("") },
Some("DPCompilerTest sourceFile doesn't exist: " + sourceFile)).get
if (source == genSrc) {
nerr match {
diff --git a/test/test/DottyTest.scala b/test/test/DottyTest.scala
index 15d82c208..4b767b318 100644
--- a/test/test/DottyTest.scala
+++ b/test/test/DottyTest.scala
@@ -23,6 +23,7 @@ class DottyTest /*extends ContextEscapeDetection*/ {
import base.settings._
val ctx = base.initialCtx.fresh
base.initialize()(ctx)
+ ctx.setSetting(ctx.settings.encoding, "UTF8")
ctx
}
/*
diff --git a/test/test/ParserTest.scala b/test/test/ParserTest.scala
index 524be272d..f66dbf55d 100644
--- a/test/test/ParserTest.scala
+++ b/test/test/ParserTest.scala
@@ -4,6 +4,7 @@ import scala.reflect.io._
import dotty.tools.dotc.util._
import dotty.tools.dotc.core._
import dotty.tools.dotc.parsing._
+import scala.io.Codec
import Tokens._, Parsers._
import dotty.tools.dotc.ast.untpd._
import org.junit.Test
@@ -23,7 +24,7 @@ class ParserTest extends DottyTest {
def parse(file: PlainFile): Tree = {
//println("***** parsing " + file)
- val source = new SourceFile(file)
+ val source = new SourceFile(file, Codec.UTF8)
val parser = new Parser(source)
val tree = parser.parse()
parsed += 1
diff --git a/test/test/ScannerTest.scala b/test/test/ScannerTest.scala
index f8f09ff6f..5ff9bba0c 100644
--- a/test/test/ScannerTest.scala
+++ b/test/test/ScannerTest.scala
@@ -1,6 +1,7 @@
package test
import scala.reflect.io._
+import scala.io.Codec
import dotty.tools.dotc.util._
import dotty.tools.dotc.parsing._
import Tokens._, Scanners._
@@ -16,8 +17,8 @@ class ScannerTest extends DottyTest {
def scan(name: String): Unit = scan(new PlainFile(name))
def scan(file: PlainFile): Unit = {
- println("***** scanning " + file)
- val source = new SourceFile(file)
+ //println("***** scanning " + file)
+ val source = new SourceFile(file, Codec.UTF8)
val scanner = new Scanner(source)
var i = 0
while (scanner.token != EOF) {