summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/ReplTest.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala
index edd1f705a4..7381b8af54 100644
--- a/src/partest/scala/tools/partest/ReplTest.scala
+++ b/src/partest/scala/tools/partest/ReplTest.scala
@@ -7,6 +7,7 @@ package scala.tools.partest
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.ILoop
+import scala.tools.partest.nest.FileUtil
import java.lang.reflect.{ Method => JMethod, Field => JField }
/** A trait for testing repl code. It drops the first line
@@ -29,3 +30,15 @@ abstract class ReplTest extends DirectTest {
}
def show() = eval() foreach println
}
+
+abstract class SessionTest extends ReplTest with FileUtil {
+ def session: String
+ override final def code = expected filter (_.startsWith(prompt)) map (_.drop(prompt.length)) mkString "\n"
+ def expected = session.stripMargin.lines.toList
+ final def prompt = "scala> "
+ override def show() = {
+ val out = eval().toList
+ if (out.size != expected.size) Console println s"Expected ${expected.size} lines, got ${out.size}"
+ if (out != expected) Console print compareContents(expected, out, "expected", "actual")
+ }
+}