diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-07 18:12:13 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-08-16 17:34:42 +0200 |
commit | b3d4fd94f24b961715dce15d7d46fcdd32f7dd69 (patch) | |
tree | efb390524c8e59d51202e6645a4a9eaa48e13afa /test | |
parent | 8d4d9a363d90cc24bd79b18ea2ef7cba6a746bef (diff) | |
download | dotty-b3d4fd94f24b961715dce15d7d46fcdd32f7dd69.tar.gz dotty-b3d4fd94f24b961715dce15d7d46fcdd32f7dd69.tar.bz2 dotty-b3d4fd94f24b961715dce15d7d46fcdd32f7dd69.zip |
Fix readLine in TestREPL to align with Ammonite reader
Needs to read several input lines at once.
Enables repl test of new error messages.
Diffstat (limited to 'test')
-rw-r--r-- | test/test/TestREPL.scala | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/test/TestREPL.scala b/test/test/TestREPL.scala index 4899607ce..1ba456ce2 100644 --- a/test/test/TestREPL.scala +++ b/test/test/TestREPL.scala @@ -24,12 +24,20 @@ class TestREPL(script: String) extends REPL { ctx.fresh.setSetting(ctx.settings.color, "never") override def input(in: Interpreter)(implicit ctx: Context) = new InteractiveReader { - val lines = script.lines + val lines = script.lines.buffered def readLine(prompt: String): String = { val line = lines.next - if (line.startsWith(prompt) || line.startsWith(continuationPrompt)) { + val buf = new StringBuilder + if (line.startsWith(prompt)) { output.println(line) - line.drop(prompt.length) + buf append line.drop(prompt.length) + while (lines.hasNext && lines.head.startsWith(continuationPrompt)) { + val continued = lines.next + output.println(continued) + buf append "\n" + buf append continued.drop(continuationPrompt.length) + } + buf.toString } else readLine(prompt) } |