diff options
Diffstat (limited to 'test/test/TestREPL.scala')
-rw-r--r-- | test/test/TestREPL.scala | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/test/test/TestREPL.scala b/test/test/TestREPL.scala index a9978cdde..30dad2b64 100644 --- a/test/test/TestREPL.scala +++ b/test/test/TestREPL.scala @@ -5,32 +5,31 @@ import dotty.tools.dotc.core.Contexts.Context import collection.mutable import java.io.StringWriter - class TestREPL(script: String) extends REPL { - private val prompt = "scala> " - private val continuationPrompt = " | " - private val out = new StringWriter() - override val output = new NewLinePrintWriter(out) - override def input(implicit ctx: Context) = new InteractiveReader { - val lines = script.lines - def readLine(prompt: String): String = { - val line = lines.next - if (line.startsWith(prompt) || line.startsWith(continuationPrompt)) { - output.println(line) - line.drop(prompt.length) + override lazy val config = new REPL.Config { + override val output = new NewLinePrintWriter(out) + + override def input(implicit ctx: Context) = new InteractiveReader { + val lines = script.lines + def readLine(prompt: String): String = { + val line = lines.next + if (line.startsWith(prompt) || line.startsWith(continuationPrompt)) { + output.println(line) + line.drop(prompt.length) + } + else readLine(prompt) } - else readLine(prompt) + val interactive = false } - val interactive = false } def check() = { out.close() val printed = out.toString - val transcript = printed.drop(printed.indexOf(prompt)) + val transcript = printed.drop(printed.indexOf(config.prompt)) if (transcript.toString != script) { println("input differs from transcript:") println(transcript) |