From b3d4fd94f24b961715dce15d7d46fcdd32f7dd69 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 7 Aug 2016 18:12:13 +0200 Subject: Fix readLine in TestREPL to align with Ammonite reader Needs to read several input lines at once. Enables repl test of new error messages. --- test/test/TestREPL.scala | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'test') 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) } -- cgit v1.2.3