summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/ast/NodePrinters.scala68
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala3
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Tokens.scala69
-rw-r--r--src/compiler/scala/tools/nsc/io/Path.scala6
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaScanners.scala12
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaTokens.scala31
-rw-r--r--src/compiler/scala/tools/nsc/util/CharArrayReader.scala15
-rwxr-xr-xsrc/compiler/scala/tools/nsc/util/Chars.scala14
-rw-r--r--src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala13
-rw-r--r--src/library/scala/xml/parsing/MarkupParser.scala72
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala124
11 files changed, 174 insertions, 253 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
index 89f036f34b..b8117ceaa4 100644
--- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
@@ -158,46 +158,27 @@ abstract class NodePrinters {
}
def nodeinfo2(tree: Tree): String =
(if (comma) "," else "") + nodeinfo(tree)
+
+ def applyCommon(name: String, tree: Tree, fun: Tree, args: List[Tree]) {
+ println(name + "(" + nodeinfo(tree))
+ traverse(fun, level + 1, true)
+ if (args.isEmpty)
+ println(" Nil // no argument")
+ else {
+ val n = args.length
+ println(" List( // " + n + " arguments(s)")
+ for (i <- 0 until n)
+ traverse(args(i), level + 2, i < n-1)
+ println(" )")
+ }
+ printcln(")")
+ }
+
tree match {
- case AppliedTypeTree(tpt, args) =>
- println("AppliedTypeTree(" + nodeinfo(tree))
- traverse(tpt, level + 1, true)
- if (args.isEmpty)
- println(" List() // no argument")
- else {
- val n = args.length
- println(" List( // " + n + " arguments(s)")
- for (i <- 0 until n)
- traverse(args(i), level + 2, i < n-1)
- println(" )")
- }
- printcln(")")
- case Apply(fun, args) =>
- println("Apply(" + nodeinfo(tree))
- traverse(fun, level + 1, true)
- if (args.isEmpty)
- println(" List() // no argument")
- else {
- val n = args.length
- println(" List( // " + n + " argument(s)")
- for (i <- 0 until n)
- traverse(args(i), level + 2, i < n-1)
- println(" )")
- }
- printcln(")")
- case ApplyDynamic(fun, args) =>
- println("ApplyDynamic(" + nodeinfo(tree))
- traverse(fun, level + 1, true)
- if (args.isEmpty)
- println(" List() // no argument")
- else {
- val n = args.length
- println(" List( // " + n + " argument(s)")
- for (i <- 0 until n)
- traverse(args(i), level + 2, i < n-1)
- println(" )")
- }
- printcln(")")
+ case AppliedTypeTree(tpt, args) => applyCommon("AppliedTypeTree", tree, tpt, args)
+ case Apply(fun, args) => applyCommon("Apply", tree, fun, args)
+ case ApplyDynamic(fun, args) => applyCommon("ApplyDynamic", tree, fun, args)
+
case Block(stats, expr) =>
println("Block(" + nodeinfo(tree))
if (stats.isEmpty)
@@ -355,16 +336,11 @@ abstract class NodePrinters {
def printUnit(unit: CompilationUnit) {
print("// Scala source: " + unit.source + "\n")
- if (unit.body ne null) {
- print(nodeToString(unit.body)); println()
- } else {
- print("<null>")
- }
- println()
+ println(Option(unit.body) map (x => nodeToString(x) + "\n") getOrElse "<null>")
}
def printAll() {
print("[[syntax trees at end of " + phase + "]]")
- for (unit <- global.currentRun.units) printUnit(unit)
+ global.currentRun.units foreach printUnit
}
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 4d1fe1c9bf..841c1709ca 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -7,12 +7,11 @@ package scala.tools.nsc
package ast.parser
import scala.tools.nsc.util._
-import Chars.{LF, FF, CR, SU}
+import Chars._
import Tokens._
import scala.annotation.switch
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
import scala.xml.Utility.{ isNameStart }
-import util.Chars._
trait Scanners {
val global : Global
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala
index 9aed4bd767..2146fa0fe6 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala
@@ -7,7 +7,14 @@
package scala.tools.nsc
package ast.parser
-object Tokens {
+import annotation.switch
+
+/** Common code between JavaTokens and Tokens. Not as much (and not as concrete)
+ * as one might like because JavaTokens for no clear reason chose new numbers for
+ * identical token sets.
+ */
+abstract class Tokens {
+ import util.Chars._
/** special tokens */
final val EMPTY = -3
@@ -22,6 +29,23 @@ object Tokens {
final val FLOATLIT = 4
final val DOUBLELIT = 5
final val STRINGLIT = 6
+
+ def LPAREN: Int
+ def RBRACE: Int
+
+ def isIdentifier(code: Int): Boolean
+ def isLiteral(code: Int): Boolean
+ def isKeyword(code: Int): Boolean
+ def isSymbol(code: Int): Boolean
+
+ final def isSpace(at: Char) = at == ' ' || at == '\t'
+ final def isNewLine(at: Char) = at == CR || at == LF || at == FF
+ final def isBrace(code : Int) = code >= LPAREN && code <= RBRACE
+ final def isOpenBrace(code : Int) = isBrace(code) && (code % 2 == 0)
+ final def isCloseBrace(code : Int) = isBrace(code) && (code % 2 == 1)
+}
+
+object Tokens extends Tokens {
final val SYMBOLLIT = 7
def isLiteral(code : Int) =
code >= CHARLIT && code <= SYMBOLLIT
@@ -32,16 +56,14 @@ object Tokens {
def isIdentifier(code : Int) =
code >= IDENTIFIER && code <= BACKQUOTED_IDENT
- def canBeginExpression(code : Int) = code match {
- case IDENTIFIER|BACKQUOTED_IDENT|USCORE => true
- case LBRACE|LPAREN|LBRACKET|COMMENT|STRINGLIT => true
- case IF|DO|WHILE|FOR|NEW|TRY|THROW => true
- case NULL|THIS|TRUE|FALSE => true
- case code if isLiteral(code) => true
- case _ => false
+ @switch def canBeginExpression(code : Int) = code match {
+ case IDENTIFIER|BACKQUOTED_IDENT|USCORE => true
+ case LBRACE|LPAREN|LBRACKET|COMMENT|STRINGLIT => true
+ case IF|DO|WHILE|FOR|NEW|TRY|THROW => true
+ case NULL|THIS|TRUE|FALSE => true
+ case code => isLiteral(code)
}
-
/** keywords */
final val IF = 20
final val FOR = 21
@@ -90,15 +112,14 @@ object Tokens {
def isKeyword(code : Int) =
code >= IF && code <= LAZY
- def isDefinition(code : Int) = code match {
- case CLASS|TRAIT|OBJECT => true
- case CASECLASS|CASEOBJECT => true
- case DEF|VAL|VAR => true
- case TYPE => true
- case _ => false
+ @switch def isDefinition(code : Int) = code match {
+ case CLASS|TRAIT|OBJECT => true
+ case CASECLASS|CASEOBJECT => true
+ case DEF|VAL|VAR => true
+ case TYPE => true
+ case _ => false
}
-
/** special symbols */
final val COMMA = 70
final val SEMI = 71
@@ -127,11 +148,6 @@ object Tokens {
final val LBRACE = 94
final val RBRACE = 95
- def isBrace(code : Int) =
- code >= LPAREN && code <= RBRACE
- def isOpenBrace(code : Int) = isBrace(code) && (code % 2 == 0)
- def isCloseBrace(code : Int) = isBrace(code) && (code % 2 == 1)
-
/** XML mode */
final val XMLSTART = 96
@@ -141,15 +157,4 @@ object Tokens {
final val WHITESPACE = 105
final val IGNORE = 106
final val ESCAPE = 109
-
- def isSpace(at : Char) = at match {
- case ' ' | '\t' => true
- case _ => false
- }
- import util.Chars._
-
- def isNewLine(at : Char) = at match {
- case CR | LF | FF => true
- case _ => false
- }
}
diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala
index 36784b6bc3..15550d2445 100644
--- a/src/compiler/scala/tools/nsc/io/Path.scala
+++ b/src/compiler/scala/tools/nsc/io/Path.scala
@@ -210,6 +210,12 @@ class Path private[io] (val jfile: JFile)
length == 0
}
+ def touch(modTime: Long = System.currentTimeMillis) = {
+ createFile()
+ if (isFile)
+ lastModified = modTime
+ }
+
// todo
// def copyTo(target: Path, options ...): Boolean
// def moveTo(target: Path, options ...): Boolean
diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
index 113f1265e5..dd9d2a87c6 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package javac
import scala.tools.nsc.util._
-import Chars.{LF, FF, CR, SU}
+import Chars._
import JavaTokens._
import scala.annotation.switch
@@ -754,13 +754,13 @@ trait JavaScanners {
in.next
if ('0' <= in.ch && in.ch <= '7') {
val leadch: Char = in.ch
- var oct: Int = in.digit2int(in.ch, 8)
+ var oct: Int = digit2int(in.ch, 8)
in.next
if ('0' <= in.ch && in.ch <= '7') {
- oct = oct * 8 + in.digit2int(in.ch, 8)
+ oct = oct * 8 + digit2int(in.ch, 8)
in.next
if (leadch <= '3' && '0' <= in.ch && in.ch <= '7') {
- oct = oct * 8 + in.digit2int(in.ch, 8)
+ oct = oct * 8 + digit2int(in.ch, 8)
in.next
}
}
@@ -840,7 +840,7 @@ trait JavaScanners {
var i = 0
val len = name.length
while (i < len) {
- val d = in.digit2int(name(i), base)
+ val d = digit2int(name(i), base)
if (d < 0) {
syntaxError("malformed integer number")
return 0
@@ -879,7 +879,7 @@ trait JavaScanners {
/** read a number into name and set base
*/
protected def getNumber {
- while (in.digit2int(in.ch, if (base < 10) 10 else base) >= 0) {
+ while (digit2int(in.ch, if (base < 10) 10 else base) >= 0) {
putChar(in.ch)
in.next
}
diff --git a/src/compiler/scala/tools/nsc/javac/JavaTokens.scala b/src/compiler/scala/tools/nsc/javac/JavaTokens.scala
index 3e0637d374..c91ecc95c2 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaTokens.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaTokens.scala
@@ -7,21 +7,8 @@
package scala.tools.nsc
package javac
-object JavaTokens {
+object JavaTokens extends ast.parser.Tokens {
- /** special tokens */
- final val EMPTY = -3
- final val UNDEF = -2
- final val ERROR = -1
- final val EOF = 0
-
- /** literals */
- final val CHARLIT = 1
- final val INTLIT = 2
- final val LONGLIT = 3
- final val FLOATLIT = 4
- final val DOUBLELIT = 5
- final val STRINGLIT = 6
def isLiteral(code : Int) =
code >= CHARLIT && code <= STRINGLIT
@@ -139,20 +126,4 @@ object JavaTokens {
final val RBRACKET = 118
final val LBRACE = 119
final val RBRACE = 120
-
- def isBrace(code : Int) =
- code >= LPAREN && code <= RBRACE
- def isOpenBrace(code : Int) = isBrace(code) && (code % 2 == 0)
- def isCloseBrace(code : Int) = isBrace(code) && (code % 2 == 1)
-
- def isSpace(at : Char) = at match {
- case ' ' | '\t' => true
- case _ => false
- }
- import util.Chars._
-
- def isNewLine(at : Char) = at match {
- case CR | LF | FF => true
- case _ => false
- }
}
diff --git a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala
index a6c9edb8d7..4d04511c1c 100644
--- a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala
+++ b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala
@@ -7,7 +7,7 @@
package scala.tools.nsc
package util
-import Chars.{LF, FF, CR, SU}
+import Chars._
abstract class CharArrayReader { self =>
@@ -84,19 +84,6 @@ abstract class CharArrayReader { self =>
}
}
- /** Convert a character digit to an Int according to given base,
- * -1 if no success */
- def digit2int(ch: Char, base: Int): Int = {
- if ('0' <= ch && ch <= '9' && ch < '0' + base)
- ch - '0'
- else if ('A' <= ch && ch < 'A' + base - 10)
- ch - 'A' + 10
- else if ('a' <= ch && ch < 'a' + base - 10)
- ch - 'a' + 10
- else
- -1
- }
-
/** A new reader that takes off at the current character position */
def lookaheadReader = new CharArrayReader {
val buf = self.buf
diff --git a/src/compiler/scala/tools/nsc/util/Chars.scala b/src/compiler/scala/tools/nsc/util/Chars.scala
index ce02b67633..0b33b9efd9 100755
--- a/src/compiler/scala/tools/nsc/util/Chars.scala
+++ b/src/compiler/scala/tools/nsc/util/Chars.scala
@@ -10,7 +10,6 @@ import annotation.{ tailrec, switch }
/** Contains constants and classifier methods for characters */
object Chars {
-
// Be very careful touching these.
// Apparently trivial changes to the way you write these constants
// will cause Scanners.scala to go from a nice efficient switch to
@@ -22,6 +21,19 @@ object Chars {
final val CR = '\u000D'
final val SU = '\u001A'
+ /** Convert a character digit to an Int according to given base,
+ * -1 if no success */
+ def digit2int(ch: Char, base: Int): Int = {
+ if ('0' <= ch && ch <= '9' && ch < '0' + base)
+ ch - '0'
+ else if ('A' <= ch && ch < 'A' + base - 10)
+ ch - 'A' + 10
+ else if ('a' <= ch && ch < 'a' + base - 10)
+ ch - 'a' + 10
+ else
+ -1
+ }
+
/** Is character a line break? */
@inline def isLineBreakChar(c: Char) = (c: @switch) match {
case LF|FF|CR|SU => true
diff --git a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala
index 731e04e4dc..ddefcc04ee 100644
--- a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala
+++ b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala
@@ -7,7 +7,7 @@
package scala.tools.nsc
package util
-import Chars.{LF, FF, CR, SU}
+import Chars._
class JavaCharArrayReader(buf: IndexedSeq[Char], start: Int, /* startline: int, startcol: int, */
decodeUni: Boolean, error: String => Unit) extends Iterator[Char] with Cloneable {
@@ -121,15 +121,4 @@ class JavaCharArrayReader(buf: IndexedSeq[Char], start: Int, /* startline: int,
def copy: JavaCharArrayReader =
new JavaCharArrayReader(buf, bp, /* nextcol, nextline, */ decodeUni, error)
-
- def digit2int(ch: Char, base: Int): Int = {
- if ('0' <= ch && ch <= '9' && ch < '0' + base)
- ch - '0'
- else if ('A' <= ch && ch < 'A' + base - 10)
- ch - 'A' + 10
- else if ('a' <= ch && ch < 'a' + base - 10)
- ch - 'a' + 10
- else
- -1
- }
}
diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala
index fdc216c3cd..38ae4a47fb 100644
--- a/src/library/scala/xml/parsing/MarkupParser.scala
+++ b/src/library/scala/xml/parsing/MarkupParser.scala
@@ -108,28 +108,28 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
md
}
- /** &lt;? prolog ::= xml S?
- * // this is a bit more lenient than necessary...
+ /** Factored out common code.
*/
- def prolog(): Tuple3[Option[String], Option[String], Option[Boolean]] = {
- var n = 0
+ private def prologOrTextDecl(isProlog: Boolean): (Option[String], Option[String], Option[Boolean]) = {
var info_ver: Option[String] = None
var info_enc: Option[String] = None
var info_stdl: Option[Boolean] = None
var m = xmlProcInstr()
+ var n = 0
- xSpaceOpt
+ if (isProlog)
+ xSpaceOpt
m("version") match {
- case null => ;
+ case null => ;
case Text("1.0") => info_ver = Some("1.0"); n += 1
case _ => reportSyntaxError("cannot deal with versions != 1.0")
}
m("encoding") match {
case null => ;
- case Text(enc) =>
+ case Text(enc) =>
if (!isValidIANAEncoding(enc))
reportSyntaxError("\"" + enc + "\" is not a valid encoding")
else {
@@ -137,51 +137,33 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
n += 1
}
}
- m("standalone") match {
- case null => ;
- case Text("yes") => info_stdl = Some(true); n += 1
- case Text("no") => info_stdl = Some(false); n += 1
- case _ => reportSyntaxError("either 'yes' or 'no' expected")
+
+ if (isProlog) {
+ m("standalone") match {
+ case null => ;
+ case Text("yes") => info_stdl = Some(true); n += 1
+ case Text("no") => info_stdl = Some(false); n += 1
+ case _ => reportSyntaxError("either 'yes' or 'no' expected")
+ }
}
if (m.length - n != 0) {
- reportSyntaxError("VersionInfo EncodingDecl? SDDecl? or '?>' expected!");
+ val s = if (isProlog) "SDDecl? " else ""
+ reportSyntaxError("VersionInfo EncodingDecl? %sor '?>' expected!" format s)
}
- //Console.println("[MarkupParser::prolog] finished parsing prolog!");
- Tuple3(info_ver,info_enc,info_stdl)
- }
-
- /** prolog, but without standalone */
- def textDecl(): Tuple2[Option[String],Option[String]] = {
-
- var info_ver: Option[String] = None
- var info_enc: Option[String] = None
- var m = xmlProcInstr()
- var n = 0
-
- m("version") match {
- case null => ;
- case Text("1.0") => info_ver = Some("1.0"); n += 1
- case _ => reportSyntaxError("cannot deal with versions != 1.0")
- }
+ (info_ver, info_enc, info_stdl)
+ }
- m("encoding") match {
- case null => ;
- case Text(enc) =>
- if (!isValidIANAEncoding(enc))
- reportSyntaxError("\"" + enc + "\" is not a valid encoding")
- else {
- info_enc = Some(enc)
- n += 1
- }
- }
+ /** &lt;? prolog ::= xml S?
+ * // this is a bit more lenient than necessary...
+ */
+ def prolog(): (Option[String], Option[String], Option[Boolean]) =
+ prologOrTextDecl(true)
- if (m.length - n != 0) {
- reportSyntaxError("VersionInfo EncodingDecl? or '?>' expected!");
- }
- Tuple2(info_ver, info_enc);
- }
+ /** prolog, but without standalone */
+ def textDecl(): (Option[String], Option[String]) =
+ prologOrTextDecl(false) match { case (x1, x2, _) => (x1, x2) }
/**
*[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 658464e2a6..3185f8fcc7 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -398,89 +398,83 @@ class Worker(val fileManager: FileManager) extends Actor {
}
}
- def runJvmTest(file: File, kind: String): LogContext =
+ def runTestCommon(file: File, kind: String, expectFailure: Boolean)(onSuccess: (File, File) => Unit): LogContext =
runInContext(file, kind, (logFile: File, outDir: File) => {
+
if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
+ val f = if (expectFailure) failCompileFilesIn _ else compileFilesIn _
+ f(file, kind, logFile, outDir)
}
- if (succeeded) { // run test
- val fileBase = basename(file.getName)
- val dir = file.getParentFile
+ else {
+ val f: (List[File], String, File) => Boolean =
+ if (expectFailure) compileMgr.shouldFailCompile _
+ else compileMgr.shouldCompile _
- //TODO: detect whether we have to use Runtime.exec
- // val useRuntime = true
- //
- // if (useRuntime)
- // execTest(outDir, logFile, fileBase)
- // else
- // execTestObjectRunner(file, outDir, logFile)
- // // NestUI.verbose(this+" finished running "+fileBase)
- execTest(outDir, logFile, fileBase)
-
- diffCheck(compareOutput(dir, fileBase, kind, logFile))
+ if (!f(List(file), kind, logFile))
+ fail(file)
}
+
+ if (succeeded) // run test
+ onSuccess(logFile, outDir)
+ })
+
+ def runJvmTest(file: File, kind: String): LogContext =
+ runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => {
+ val fileBase = basename(file.getName)
+ val dir = file.getParentFile
+
+ //TODO: detect whether we have to use Runtime.exec
+ // val useRuntime = true
+ //
+ // if (useRuntime)
+ // execTest(outDir, logFile, fileBase)
+ // else
+ // execTestObjectRunner(file, outDir, logFile)
+ // // NestUI.verbose(this+" finished running "+fileBase)
+ execTest(outDir, logFile, fileBase)
+
+ diffCheck(compareOutput(dir, fileBase, kind, logFile))
})
def processSingleFile(file: File): LogContext = kind match {
case "scalacheck" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
- }
- if (succeeded) {
- val consFM = new ConsoleFileManager
- import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
-
- NestUI.verbose("compilation of "+file+" succeeded\n")
+ runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => {
+ val consFM = new ConsoleFileManager
+ import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
- val libs = new File(fileManager.LIB_DIR)
- val scalacheckURL = (new File(libs, "ScalaCheck.jar")).toURI.toURL
- val outURL = outDir.getCanonicalFile.toURI.toURL
- val classpath: List[URL] =
- List(outURL, scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL).distinct
+ NestUI.verbose("compilation of "+file+" succeeded\n")
- val logWriter = new PrintStream(new FileOutputStream(logFile))
+ val libs = new File(fileManager.LIB_DIR)
+ val scalacheckURL = (new File(libs, "ScalaCheck.jar")).toURI.toURL
+ val outURL = outDir.getCanonicalFile.toURI.toURL
+ val classpath: List[URL] =
+ List(outURL, scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL).distinct
- withOutputRedirected(logWriter) {
- ObjectRunner.run(classpath, "Test", Nil)
- }
+ val logWriter = new PrintStream(new FileOutputStream(logFile))
- NestUI.verbose(SFile(logFile).slurp())
- // obviously this must be improved upon
- succeeded = SFile(logFile).lines() forall (_ contains " OK")
+ withOutputRedirected(logWriter) {
+ ObjectRunner.run(classpath, "Test", Nil)
}
- })
+
+ NestUI.verbose(SFile(logFile).slurp())
+ // obviously this must be improved upon
+ succeeded = SFile(logFile).lines() forall (_ contains " OK")
+ })
case "pos" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
- }
- })
+ runTestCommon(file, kind, expectFailure = false)((_, _) => ())
case "neg" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- failCompileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldFailCompile(List(file), kind, logFile)) {
- succeeded = false
- }
- if (succeeded) { // compare log file to check file
- val fileBase = basename(file.getName)
- val dir = file.getParentFile
-
- diffCheck(
- // diff is contents of logFile
- if (!existsCheckFile(dir, fileBase, kind)) file2String(logFile)
- else compareOutput(dir, fileBase, kind, logFile)
- )
- }
+ runTestCommon(file, kind, expectFailure = true)((logFile, outDir) => {
+ // compare log file to check file
+ val fileBase = basename(file.getName)
+ val dir = file.getParentFile
+
+ diffCheck(
+ // diff is contents of logFile
+ if (!existsCheckFile(dir, fileBase, kind)) file2String(logFile)
+ else compareOutput(dir, fileBase, kind, logFile)
+ )
})
case "run" | "jvm" =>