summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-28 21:23:59 +0000
committerPaul Phillips <paulp@improving.org>2011-02-28 21:23:59 +0000
commitfdaa0a7a0178eab124d65f96e872c07c4400c94a (patch)
tree2d2e8c1214e7fb253954ac1e73e616d06d9de7e6
parent34719ee9cb51650550cfcf849178cf5da5a93dd5 (diff)
downloadscala-fdaa0a7a0178eab124d65f96e872c07c4400c94a.tar.gz
scala-fdaa0a7a0178eab124d65f96e872c07c4400c94a.tar.bz2
scala-fdaa0a7a0178eab124d65f96e872c07c4400c94a.zip
Break 9 tests, fix 9 tests, realize you broke t...
Break 9 tests, fix 9 tests, realize you broke the test you checked in between +9 and -9. Fix that and generalize the repl tests a little. I think we're all the way there. No review.
-rw-r--r--src/partest/scala/tools/partest/ReplTest.scala19
-rw-r--r--test/files/jvm/interpreter.scala17
-rw-r--r--test/files/run/bug3376.scala9
-rw-r--r--test/files/run/bug4285.check9
-rw-r--r--test/files/run/bug4285.scala13
5 files changed, 41 insertions, 26 deletions
diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala
new file mode 100644
index 0000000000..232d605bb0
--- /dev/null
+++ b/src/partest/scala/tools/partest/ReplTest.scala
@@ -0,0 +1,19 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala.tools.partest
+
+import scala.tools.nsc.interpreter.ILoop
+
+/** A trait for testing repl code. It drops the first line
+ * of output because the real repl prints a version number.
+ */
+abstract class ReplTest extends App {
+ def code: String
+ def eval() = (ILoop run code).lines drop 1
+ def show() = eval() foreach println
+
+ show()
+}
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala
index 70ad900305..752a129950 100644
--- a/test/files/jvm/interpreter.scala
+++ b/test/files/jvm/interpreter.scala
@@ -1,11 +1,8 @@
import scala.tools.nsc._
-import java.io.{BufferedReader, StringReader, PrintWriter,
- Writer, OutputStreamWriter}
+import scala.tools.partest.ReplTest
-import interpreter.ILoop
-
-object Test {
- val testCodeString = <code>
+object Test extends ReplTest {
+ def code = <code>
// basics
3+4
def gcd(x: Int, y: Int): Int = {{
@@ -146,11 +143,7 @@ def f(e: Exp) = e match {{ // non-exhaustive warning here
</code>.text
- def main(args: Array[String]) {
- // This drops the first line of output because the repl
- // prints a version number.
- (ILoop run testCodeString).lines drop 1 foreach println
-
+ def appendix() = {
val settings = new Settings
settings.classpath.value = sys.props("java.class.path")
val interp = new Interpreter(settings)
@@ -160,4 +153,6 @@ def f(e: Exp) = e match {{ // non-exhaustive warning here
interp.interpret("\"after reset\"")
interp.interpret("plusOne(5) // should be undefined now")
}
+
+ appendix()
}
diff --git a/test/files/run/bug3376.scala b/test/files/run/bug3376.scala
index 5cff50185c..e2c94e5072 100644
--- a/test/files/run/bug3376.scala
+++ b/test/files/run/bug3376.scala
@@ -1,16 +1,13 @@
import scala.tools.nsc.interpreter._
+import scala.tools.partest.ReplTest
-object Test {
+object Test extends ReplTest {
class M[@specialized T] { }
- val code = """
+ def code = """
|class M[@specialized T] { override def toString = "mmm" }
|val m1 = new M[Int]()
|val m2 = new M[Float]()
|val m3 = new M[String]()
|""".stripMargin
-
- def main(args: Array[String]): Unit = {
- (ILoop run code).lines drop 1 foreach println
- }
}
diff --git a/test/files/run/bug4285.check b/test/files/run/bug4285.check
index 6f906f80a6..5a3c9811c3 100644
--- a/test/files/run/bug4285.check
+++ b/test/files/run/bug4285.check
@@ -1,9 +1,12 @@
-Welcome to Scala version 2.9.0.r24351-b20110228153004 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.
+scala>
+scala> x: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7)
+
+scala> y: scala.collection.mutable.WrappedArray[Int] = WrappedArray(2, 4, 6, 8, 10, 12, 14)
+
scala> 56
-x: Array[Int] = Array(2, 4, 6, 8, 10, 12, 14)
-y: scala.collection.mutable.WrappedArray[Int] = WrappedArray(2, 4, 6, 8, 10, 12, 14)
scala>
+scala>
diff --git a/test/files/run/bug4285.scala b/test/files/run/bug4285.scala
index 9e89b13a3a..1d9afcaf3d 100644
--- a/test/files/run/bug4285.scala
+++ b/test/files/run/bug4285.scala
@@ -1,7 +1,8 @@
-object Test {
- def main(args: Array[String]): Unit = {
- println(scala.tools.nsc.interpreter.ILoop.run("val x = Array(1,2,3,4,5,6,7) ; val y = x transform (_ * 2) ; println(y.sum)"))
- }
+import scala.tools.partest.ReplTest
+object Test extends ReplTest {
+ def code = """
+ |val x = Array(1,2,3,4,5,6,7)
+ |val y = x transform (_ * 2)
+ |println(y.sum)
+ """.stripMargin
}
-
-