summaryrefslogtreecommitdiff
path: root/src/partest-extras
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2015-06-20 13:52:34 -0700
committerSom Snytt <som.snytt@gmail.com>2015-06-21 10:29:04 -0700
commit3bfafbcf5903fc5c43190f1738c50bbbe0ca7d2b (patch)
tree41a0c371a8dc3de469f4c021b618f03610dcc524 /src/partest-extras
parenta9053f429983cc322a2fd2eca8fd0188036c7378 (diff)
downloadscala-3bfafbcf5903fc5c43190f1738c50bbbe0ca7d2b.tar.gz
scala-3bfafbcf5903fc5c43190f1738c50bbbe0ca7d2b.tar.bz2
scala-3bfafbcf5903fc5c43190f1738c50bbbe0ca7d2b.zip
SI-9206 Accept paste with custom prompt
But sans test.
Diffstat (limited to 'src/partest-extras')
-rw-r--r--src/partest-extras/scala/tools/partest/ReplTest.scala12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/partest-extras/scala/tools/partest/ReplTest.scala b/src/partest-extras/scala/tools/partest/ReplTest.scala
index 5b65d6ab9b..1fde2370d3 100644
--- a/src/partest-extras/scala/tools/partest/ReplTest.scala
+++ b/src/partest-extras/scala/tools/partest/ReplTest.scala
@@ -75,18 +75,20 @@ abstract class SessionTest extends ReplTest {
* Retain user input: prompt lines and continuations, without the prefix; or pasted text plus ctl-D.
*/
import SessionTest._
- override final def code = input findAllMatchIn (expected mkString ("", "\n", "\n")) map {
- case input(null, null, prompted) =>
+ lazy val pasted = input(prompt)
+ override final def code = pasted findAllMatchIn (expected mkString ("", "\n", "\n")) map {
+ case pasted(null, null, prompted) =>
def continued(m: Match): Option[String] = m match {
case margin(text) => Some(text)
case _ => None
}
margin.replaceSomeIn(prompted, continued)
- case input(cmd, pasted, null) =>
+ case pasted(cmd, pasted, null) =>
cmd + pasted + "\u0004"
} mkString
- final def prompt = "scala> "
+ // Just the last line of the interactive prompt
+ def prompt = "scala> "
/** Default test is to compare expected and actual output and emit the diff on a failed comparison. */
override def show() = {
@@ -98,7 +100,7 @@ abstract class SessionTest extends ReplTest {
}
object SessionTest {
// \R for line break is Java 8, \v for vertical space might suffice
- val input = """(?m)^scala> (:pa.*\u000A)// Entering paste mode.*\u000A\u000A((?:.*\u000A)*)\u000A// Exiting paste mode.*\u000A|^scala> (.*\u000A(?:\s*\| .*\u000A)*)""".r
+ def input(prompt: String) = s"""(?m)^$prompt(:pa.*\u000A)// Entering paste mode.*\u000A\u000A((?:.*\u000A)*)\u000A// Exiting paste mode.*\u000A|^scala> (.*\u000A(?:\\s*\\| .*\u000A)*)""".r
val margin = """(?m)^\s*\| (.*)$""".r
}