diff options
-rw-r--r-- | src/partest-extras/scala/tools/partest/ReplTest.scala | 5 | ||||
-rw-r--r-- | test/files/run/repl-trim-stack-trace.scala | 13 |
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 } |