@@ -4,6 +4,7 @@ package dotc
4
4
package transform
5
5
6
6
import java .io ._
7
+ import java .nio .file .{Path => JPath }
7
8
8
9
import scala .io .Source ._
9
10
import dotty .tools .io .Directory
@@ -16,53 +17,53 @@ class PatmatExhaustivityTest {
16
17
// stop-after: patmatexhaust-huge.scala crash compiler
17
18
val options = List (" -color:never" , " -Ystop-after:splitter" , " -Ycheck-all-patmat" , " -classpath" , TestConfiguration .classPath)
18
19
19
- private def compileFile (file : File ) = {
20
+ private def compileFile (path : JPath ) = {
20
21
val stringBuffer = new StringWriter ()
21
22
val reporter = TestReporter .simplifiedReporter(new PrintWriter (stringBuffer))
22
23
23
24
try {
24
- Main .process((file.getPath :: options).toArray, reporter, null )
25
+ Main .process((path.toString :: options).toArray, reporter, null )
25
26
} catch {
26
27
case e : Throwable =>
27
- println(s " Compile $file exception: " )
28
+ println(s " Compile $path exception: " )
28
29
e.printStackTrace()
29
30
}
30
31
31
32
val actual = stringBuffer.toString.trim.replaceAll(" \\ s+\n " , " \n " )
32
- val checkFilePath = file.getAbsolutePath .stripSuffix(" .scala" ) + " .check"
33
+ val checkFilePath = path.toAbsolutePath.toString .stripSuffix(" .scala" ) + " .check"
33
34
val checkContent =
34
35
if (new File (checkFilePath).exists)
35
36
fromFile(checkFilePath).getLines().map(_.replaceAll(" \\ s+$" , " " )).mkString(" \n " ).trim
36
37
else " "
37
38
38
- (file , checkContent, actual)
39
+ (path , checkContent, actual)
39
40
}
40
41
41
42
/** A single test with multiple files grouped in a folder */
42
- private def compileDir (file : File ) = {
43
+ private def compileDir (path : JPath ) = {
43
44
val stringBuffer = new StringWriter ()
44
45
val reporter = TestReporter .simplifiedReporter(new PrintWriter (stringBuffer))
45
46
46
- val files = Directory (file.getPath ).list.toList
47
+ val files = Directory (path ).list.toList
47
48
.filter(f => f.extension == " scala" || f.extension == " java" )
48
- .map(_.jfile.getPath )
49
+ .map(_.jpath.toString )
49
50
50
51
try {
51
52
Main .process((options ++ files).toArray, reporter, null )
52
53
} catch {
53
54
case e : Throwable =>
54
- println(s " Compile $file exception: " )
55
+ println(s " Compile $path exception: " )
55
56
e.printStackTrace()
56
57
}
57
58
58
59
val actual = stringBuffer.toString.trim.replaceAll(" \\ s+\n " , " \n " )
59
- val checkFilePath = file.getPath + File .separator + " expected.check"
60
+ val checkFilePath = path + File .separator + " expected.check"
60
61
val checkContent =
61
62
if (new File (checkFilePath).exists)
62
63
fromFile(checkFilePath).getLines().map(_.replaceAll(" \\ s+$" , " " )).mkString(" \n " ).trim
63
64
else " "
64
65
65
- (file , checkContent, actual)
66
+ (path , checkContent, actual)
66
67
}
67
68
68
69
@ Test
@@ -71,9 +72,9 @@ class PatmatExhaustivityTest {
71
72
.filter(f => f.extension == " scala" || f.isDirectory)
72
73
.map { f =>
73
74
if (f.isDirectory)
74
- compileDir(f.jfile )
75
+ compileDir(f.jpath )
75
76
else
76
- compileFile(f.jfile )
77
+ compileFile(f.jpath )
77
78
}
78
79
79
80
val failed = res.filter { case (_, expected, actual) => expected != actual }
0 commit comments