blob: a9978cdde48afee67df5d19babbeee1d3a002d54 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package test
import dotty.tools.dotc.repl._
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)
}
else readLine(prompt)
}
val interactive = false
}
def check() = {
out.close()
val printed = out.toString
val transcript = printed.drop(printed.indexOf(prompt))
if (transcript.toString != script) {
println("input differs from transcript:")
println(transcript)
assert(false)
}
}
}
|