@@ -39,7 +39,9 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
3939 extension [A ](state : State )
4040 def andThen (op : State => A ): A = op(state)
4141
42- def testFile (f : JFile ): Unit = {
42+ def testFile (f : JFile ): Unit = testScript(f.toString, readLines(f))
43+
44+ def testScript (name : => String , lines : List [String ]): Unit = {
4345 val prompt = " scala>"
4446
4547 def evaluate (state : State , input : String ) =
@@ -50,7 +52,7 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
5052 }
5153 catch {
5254 case ex : Throwable =>
53- System .err.println(s " failed while running script: $f , on: \n $input" )
55+ System .err.println(s " failed while running script: $name , on: \n $input" )
5456 throw ex
5557 }
5658
@@ -60,13 +62,12 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
6062 case nonEmptyLine => nonEmptyLine :: Nil
6163 }
6264
63- val expectedOutput = readLines(f) .flatMap(filterEmpties)
65+ val expectedOutput = lines .flatMap(filterEmpties)
6466 val actualOutput = {
6567 resetToInitial()
6668
67- val lines = readLines(f)
6869 assert(lines.head.startsWith(prompt),
69- s """ Each file has to start with the prompt: " $prompt" """ )
70+ s """ Each script must start with the prompt: " $prompt" """ )
7071 val inputRes = lines.filter(_.startsWith(prompt))
7172
7273 val buf = new ArrayBuffer [String ]
@@ -88,7 +89,7 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
8889 println(" actual ===========>" )
8990 println(actualOutput.mkString(EOL ))
9091
91- fail(s " Error in file $f , expected output did not match actual " )
92+ fail(s " Error in script $name , expected output did not match actual " )
9293 end if
9394 }
9495}
0 commit comments