@@ -19,17 +19,18 @@ import scala.io.Source
19
19
import org .junit .Test
20
20
21
21
class PrintingTest {
22
- val testsDir = " tests/printing"
23
- val options = List (" -Xprint:typer" , " -color:never" , " -classpath" , TestConfiguration .basicClasspath)
24
22
25
- private def compileFile (path : JPath ): Boolean = {
23
+ def options (phase : String ) =
24
+ List (s " -Xprint: $phase" , " -color:never" , " -classpath" , TestConfiguration .basicClasspath)
25
+
26
+ private def compileFile (path : JPath , phase : String ): Boolean = {
26
27
val baseFilePath = path.toString.stripSuffix(" .scala" )
27
28
val checkFilePath = baseFilePath + " .check"
28
29
val byteStream = new ByteArrayOutputStream ()
29
30
val reporter = TestReporter .reporter(new PrintStream (byteStream), INFO )
30
31
31
32
try {
32
- Main .process((path.toString:: options).toArray, reporter, null )
33
+ Main .process((path.toString:: options(phase) ).toArray, reporter, null )
33
34
} catch {
34
35
case e : Throwable =>
35
36
println(s " Compile $path exception: " )
@@ -40,11 +41,10 @@ class PrintingTest {
40
41
FileDiff .checkAndDump(path.toString, actualLines.toIndexedSeq, checkFilePath)
41
42
}
42
43
43
- @ Test
44
- def printing : Unit = {
44
+ def testIn (testsDir : String , phase : String ) =
45
45
val res = Directory (testsDir).list.toList
46
46
.filter(f => f.extension == " scala" )
47
- .map { f => compileFile(f.jpath) }
47
+ .map { f => compileFile(f.jpath, phase ) }
48
48
49
49
val failed = res.filter(! _)
50
50
@@ -53,5 +53,12 @@ class PrintingTest {
53
53
assert(failed.length == 0 , msg)
54
54
55
55
println(msg)
56
- }
56
+
57
+ end testIn
58
+
59
+ @ Test
60
+ def printing : Unit = testIn(" tests/printing" , " typer" )
61
+
62
+ @ Test
63
+ def untypedPrinting : Unit = testIn(" tests/printing/untyped" , " parser" )
57
64
}
0 commit comments