@@ -20,7 +20,15 @@ class ScriptedTests extends ReplTest with MessageRendering {
20
20
dir.listFiles
21
21
}
22
22
23
- private def testFile (f : JFile ): Unit = {
23
+ def filterEmpties (line : String ): List [String ] =
24
+ line.replaceAll(""" (?m)\s+$""" , " " ) match {
25
+ case " " => Nil
26
+ case nonEmptyLine => nonEmptyLine :: Nil
27
+ }
28
+
29
+ def noChange (line : String ): List [String ] = List (line)
30
+
31
+ private def testFile (changeLines : String => List [String ])(f : JFile ): Unit = {
24
32
val prompt = " scala>"
25
33
val lines = Source .fromFile(f).getLines.buffered
26
34
@@ -53,14 +61,9 @@ class ScriptedTests extends ReplTest with MessageRendering {
53
61
throw ex
54
62
}
55
63
56
- def filterEmpties (line : String ): List [String ] =
57
- line.replaceAll(""" (?m)\s+$""" , " " ) match {
58
- case " " => Nil
59
- case nonEmptyLine => nonEmptyLine :: Nil
60
- }
61
64
62
65
val expectedOutput =
63
- Source .fromFile(f).getLines.flatMap(filterEmpties ).mkString(" \n " )
66
+ Source .fromFile(f).getLines.flatMap(changeLines ).mkString(" \n " )
64
67
val actualOutput = {
65
68
resetToInitial()
66
69
init()
@@ -71,7 +74,7 @@ class ScriptedTests extends ReplTest with MessageRendering {
71
74
buf.append(out)
72
75
nstate
73
76
}
74
- buf.flatMap(filterEmpties ).mkString(" \n " )
77
+ buf.flatMap(changeLines ).mkString(" \n " )
75
78
}
76
79
77
80
if (expectedOutput != actualOutput) {
@@ -84,7 +87,9 @@ class ScriptedTests extends ReplTest with MessageRendering {
84
87
}
85
88
}
86
89
87
- @ Test def replTests = scripts(" /repl" ).foreach(testFile)
90
+ @ Test def replTests = scripts(" /repl" ).foreach(testFile(filterEmpties))
91
+
92
+ @ Test def replWhitespaceTests = scripts(" /repl-whitespace-sensitive" ).foreach(testFile(noChange))
88
93
89
- @ Test def typePrinterTests = scripts(" /type-printer" ).foreach(testFile)
94
+ @ Test def typePrinterTests = scripts(" /type-printer" ).foreach(testFile(filterEmpties) )
90
95
}
0 commit comments