@@ -19,17 +19,18 @@ import scala.io.Source
1919import org .junit .Test
2020
2121class PrintingTest {
22- val testsDir = " tests/printing"
23- val options = List (" -Xprint:typer" , " -color:never" , " -classpath" , TestConfiguration .basicClasspath)
2422
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 = {
2627 val baseFilePath = path.toString.stripSuffix(" .scala" )
2728 val checkFilePath = baseFilePath + " .check"
2829 val byteStream = new ByteArrayOutputStream ()
2930 val reporter = TestReporter .reporter(new PrintStream (byteStream), INFO )
3031
3132 try {
32- Main .process((path.toString:: options).toArray, reporter, null )
33+ Main .process((path.toString:: options(phase) ).toArray, reporter, null )
3334 } catch {
3435 case e : Throwable =>
3536 println(s " Compile $path exception: " )
@@ -40,11 +41,10 @@ class PrintingTest {
4041 FileDiff .checkAndDump(path.toString, actualLines.toIndexedSeq, checkFilePath)
4142 }
4243
43- @ Test
44- def printing : Unit = {
44+ def testIn (testsDir : String , phase : String ) =
4545 val res = Directory (testsDir).list.toList
4646 .filter(f => f.extension == " scala" )
47- .map { f => compileFile(f.jpath) }
47+ .map { f => compileFile(f.jpath, phase ) }
4848
4949 val failed = res.filter(! _)
5050
@@ -53,5 +53,12 @@ class PrintingTest {
5353 assert(failed.length == 0 , msg)
5454
5555 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" )
5764}
0 commit comments