summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-09-02 07:56:03 -0700
committerSom Snytt <som.snytt@gmail.com>2013-09-02 18:59:15 -0700
commit534ced4885e75d89025d569cc2cbc2da8ed45cab (patch)
treebceb101a6cfd9aedcc7c1c0ba99859f6c69fb9c7
parentc88e8be97777bd7bf1c8392a83f17e1583de2ffd (diff)
downloadscala-534ced4885e75d89025d569cc2cbc2da8ed45cab.tar.gz
scala-534ced4885e75d89025d569cc2cbc2da8ed45cab.tar.bz2
scala-534ced4885e75d89025d569cc2cbc2da8ed45cab.zip
SI-7781 Improve test and add comment
The test should normalize the elided message, not strip it. (Thanks qerub; I was frustrated with kitteh's turnaround that night, hence unwilling to improve once it passed.)
-rw-r--r--src/partest-extras/scala/tools/partest/ReplTest.scala5
-rw-r--r--test/files/run/repl-trim-stack-trace.scala13
2 files changed, 13 insertions, 5 deletions
diff --git a/src/partest-extras/scala/tools/partest/ReplTest.scala b/src/partest-extras/scala/tools/partest/ReplTest.scala
index 7cc2dd39a9..54d1d04a02 100644
--- a/src/partest-extras/scala/tools/partest/ReplTest.scala
+++ b/src/partest-extras/scala/tools/partest/ReplTest.scala
@@ -30,6 +30,11 @@ abstract class ReplTest extends DirectTest {
def show() = eval() foreach println
}
+/** Run a REPL test from a session transcript.
+ * The `session` should be a triple-quoted String starting
+ * with the `Type in expressions` message and ending
+ * after the final `prompt`, including the last space.
+ */
abstract class SessionTest extends ReplTest {
def session: String
override final def code = expected filter (_.startsWith(prompt)) map (_.drop(prompt.length)) mkString "\n"
diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala
index db42b37fdd..0f4a43bc85 100644
--- a/test/files/run/repl-trim-stack-trace.scala
+++ b/test/files/run/repl-trim-stack-trace.scala
@@ -33,9 +33,12 @@ java.lang.Exception
scala> """
- // remove the "elided" lines because the frame count is variable
- lazy val elided = """\s+\.{3} (?:\d+) elided""".r
- def filtered(lines: Seq[String]) = lines filter { case elided() => false ; case _ => true }
- override def eval() = filtered(super.eval().toSeq).iterator
- override def expected = filtered(super.expected).toList
+ // normalize the "elided" lines because the frame count depends on test context
+ lazy val elided = """(\s+\.{3} )\d+( elided)""".r
+ def normalize(line: String) = line match {
+ case elided(ellipsis, suffix) => s"$ellipsis???$suffix"
+ case s => s
+ }
+ override def eval() = super.eval() map normalize
+ override def expected = super.expected map normalize
}