@@ -20,7 +20,15 @@ class ScriptedTests extends ReplTest with MessageRendering {
2020 dir.listFiles
2121 }
2222
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 = {
2432 val prompt = " scala>"
2533 val lines = Source .fromFile(f).getLines.buffered
2634
@@ -53,14 +61,9 @@ class ScriptedTests extends ReplTest with MessageRendering {
5361 throw ex
5462 }
5563
56- def filterEmpties (line : String ): List [String ] =
57- line.replaceAll(""" (?m)\s+$""" , " " ) match {
58- case " " => Nil
59- case nonEmptyLine => nonEmptyLine :: Nil
60- }
6164
6265 val expectedOutput =
63- Source .fromFile(f).getLines.flatMap(filterEmpties ).mkString(" \n " )
66+ Source .fromFile(f).getLines.flatMap(changeLines ).mkString(" \n " )
6467 val actualOutput = {
6568 resetToInitial()
6669 init()
@@ -71,7 +74,7 @@ class ScriptedTests extends ReplTest with MessageRendering {
7174 buf.append(out)
7275 nstate
7376 }
74- buf.flatMap(filterEmpties ).mkString(" \n " )
77+ buf.flatMap(changeLines ).mkString(" \n " )
7578 }
7679
7780 if (expectedOutput != actualOutput) {
@@ -84,7 +87,9 @@ class ScriptedTests extends ReplTest with MessageRendering {
8487 }
8588 }
8689
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))
8893
89- @ Test def typePrinterTests = scripts(" /type-printer" ).foreach(testFile)
94+ @ Test def typePrinterTests = scripts(" /type-printer" ).foreach(testFile(filterEmpties) )
9095}
0 commit comments