@@ -20,50 +20,39 @@ class PatmatExhaustivityTest {
20
20
// stop-after: patmatexhaust-huge.scala crash compiler
21
21
val options = List (" -color:never" , " -Ystop-after:crossCast" , " -Ycheck-all-patmat" , " -classpath" , TestConfiguration .basicClasspath)
22
22
23
- private def compileFile ( path : JPath ): Boolean = {
23
+ private def compile ( files : Seq [ String ] ): Seq [ String ] = {
24
24
val stringBuffer = new StringWriter ()
25
25
val reporter = TestReporter .simplifiedReporter(new PrintWriter (stringBuffer))
26
26
27
27
try {
28
- Main .process((path.toString :: options).toArray, reporter, null )
28
+ Main .process((options ++ files ).toArray, reporter, null )
29
29
} catch {
30
30
case e : Throwable =>
31
- println(s " Compile $path exception: " )
31
+ println(s " Compile $files exception: " )
32
32
e.printStackTrace()
33
33
}
34
34
35
- val actualLines : Seq [ String ] = stringBuffer.toString.trim.replaceAll(" \\ s+\n " , " \n " ) match {
35
+ stringBuffer.toString.trim.replaceAll(" \\ s+\n " , " \n " ) match {
36
36
case " " => Nil
37
- case s => s.split( " \\ r? \\ n " ).toIndexedSeq
37
+ case s => s.linesIterator.toSeq
38
38
}
39
- val baseFilePath = path.toString.stripSuffix(" .scala" )
39
+ }
40
+
41
+ private def compileFile (path : JPath ): Boolean = {
42
+ val actualLines = compile(path.toString :: Nil )
43
+ val baseFilePath = path.toString.stripSuffix(" .scala" )
40
44
val checkFilePath = baseFilePath + " .check"
41
45
42
46
FileDiff .checkAndDump(path.toString, actualLines, checkFilePath)
43
47
}
44
48
45
49
/** A single test with multiple files grouped in a folder */
46
50
private def compileDir (path : JPath ): Boolean = {
47
- val stringBuffer = new StringWriter ()
48
- val reporter = TestReporter .simplifiedReporter(new PrintWriter (stringBuffer))
49
-
50
51
val files = Directory (path).list.toList
51
52
.filter(f => f.extension == " scala" || f.extension == " java" )
52
53
.map(_.jpath.toString)
53
54
54
- try {
55
- Main .process((options ++ files).toArray, reporter, null )
56
- } catch {
57
- case e : Throwable =>
58
- println(s " Compile $path exception: " )
59
- e.printStackTrace()
60
- }
61
-
62
- val actualLines : Seq [String ] = stringBuffer.toString.trim.replaceAll(" \\ s+\n " , " \n " ) match {
63
- case " " => Nil
64
- case s => s.split(" \\ r?\\ n" ).toIndexedSeq
65
- }
66
-
55
+ val actualLines = compile(files)
67
56
val checkFilePath = s " ${path}${File .separator}expected.check "
68
57
69
58
FileDiff .checkAndDump(path.toString, actualLines, checkFilePath)
0 commit comments