1
1
package dotty .tools
2
2
package vulpix
3
3
4
- import scala .language .unsafeNulls
5
-
6
- import java .io .{File => JFile }
7
- import org .junit .Assert ._
8
- import org .junit .{ Test , AfterClass }
9
-
10
- import scala .concurrent .duration ._
11
- import scala .util .control .NonFatal
4
+ import org .junit .{Test as test , AfterClass as tearDown }
12
5
13
6
/** Unit tests for the Vulpix test suite */
14
- class VulpixUnitTests {
15
- import VulpixUnitTests ._
16
- import TestConfiguration ._
7
+ class VulpixUnitTests :
8
+ import VulpixUnitTests .*
9
+ import TestConfiguration .*
17
10
18
- implicit val _: SummaryReporting = new NoSummaryReport
11
+ given SummaryReporting = new NoSummaryReport
19
12
20
- implicit def testGroup : TestGroup = TestGroup (" VulpixTests" )
13
+ given TestGroup = TestGroup (" VulpixTests" )
21
14
22
- // To fail with something else than an AssertionError
23
- def fail (): Unit = throw new Exception (" didn't fail properly" )
24
-
25
- @ Test def missingFile : Unit =
26
- try {
15
+ @ test def missingFile : Unit =
16
+ assertThrows[IllegalArgumentException ](_ => true ):
27
17
compileFile(" tests/vulpix-tests/unit/i-dont-exist.scala" , defaultOptions).expectFailure.checkExpectedErrors()
28
- fail()
29
- } catch {
30
- case _ : IllegalArgumentException => // pass!
31
- }
32
18
33
- @ Test def pos1Error : Unit =
19
+ @ test def pos1Error : Unit =
34
20
compileFile(" tests/vulpix-tests/unit/posFail1Error.scala" , defaultOptions).expectFailure.checkCompile()
35
21
36
- @ Test def negMissingAnnot : Unit =
37
- compileFile(" tests/vulpix-tests/unit/negMissingAnnot.scala" , defaultOptions).expectFailure.checkExpectedErrors()
38
-
39
- @ Test def negAnnotWrongLine : Unit =
40
- compileFile(" tests/vulpix-tests/unit/negAnnotWrongLine.scala" , defaultOptions).expectFailure.checkExpectedErrors()
41
-
42
- @ Test def negTooManyAnnots : Unit =
43
- compileFile(" tests/vulpix-tests/unit/negTooManyAnnots.scala" , defaultOptions).expectFailure.checkExpectedErrors()
44
-
45
- @ Test def negNoPositionAnnot : Unit =
46
- compileFile(" tests/vulpix-tests/unit/negNoPositionAnnots.scala" , defaultOptions).expectFailure.checkExpectedErrors()
47
-
48
- @ Test def negAnyPositionAnnot : Unit =
49
- compileFile(" tests/vulpix-tests/unit/negAnyPositionAnnots.scala" , defaultOptions).checkExpectedErrors()
50
-
51
- @ Test def runCompileFail : Unit =
22
+ @ test def negMissingAnnot : Unit =
23
+ compileFile(" tests/vulpix-tests/unit/negMissingAnnot.scala" , defaultOptions)
24
+ .suppressAllOutput
25
+ .expectFailure
26
+ .checkExpectedErrors()
27
+
28
+ @ test def negAnnotWrongLine : Unit =
29
+ compileFile(" tests/vulpix-tests/unit/negAnnotWrongLine.scala" , defaultOptions)
30
+ .suppressAllOutput
31
+ .expectFailure
32
+ .checkExpectedErrors()
33
+
34
+ @ test def negTooManyAnnots : Unit =
35
+ compileFile(" tests/vulpix-tests/unit/negTooManyAnnots.scala" , defaultOptions)
36
+ .suppressAllOutput
37
+ .expectFailure
38
+ .checkExpectedErrors()
39
+
40
+ @ test def negNoPositionAnnot : Unit =
41
+ compileFile(" tests/vulpix-tests/unit/negNoPositionAnnots.scala" , defaultOptions)
42
+ .suppressAllOutput
43
+ .expectFailure
44
+ .checkExpectedErrors()
45
+
46
+ @ test def negAnyPositionAnnot : Unit =
47
+ compileFile(" tests/vulpix-tests/unit/negAnyPositionAnnots.scala" , defaultOptions)
48
+ .suppressAllOutput
49
+ .checkExpectedErrors()
50
+
51
+ @ test def runCompileFail : Unit =
52
52
compileFile(" tests/vulpix-tests/unit/posFail1Error.scala" , defaultOptions).expectFailure.checkRuns()
53
53
54
- @ Test def runWrongOutput1 : Unit =
54
+ @ test def runWrongOutput1 : Unit =
55
55
compileFile(" tests/vulpix-tests/unit/runWrongOutput1.scala" , defaultOptions).expectFailure.checkRuns()
56
56
57
- @ Test def runWrongOutput2 : Unit =
57
+ @ test def runWrongOutput2 : Unit =
58
58
compileFile(" tests/vulpix-tests/unit/runWrongOutput2.scala" , defaultOptions).expectFailure.checkRuns()
59
59
60
- @ Test def runDiffOutput1 : Unit =
60
+ @ test def runDiffOutput1 : Unit =
61
61
compileFile(" tests/vulpix-tests/unit/runDiffOutput1.scala" , defaultOptions).expectFailure.checkRuns()
62
62
63
- @ Test def runStackOverflow : Unit =
63
+ @ test def runStackOverflow : Unit =
64
64
compileFile(" tests/vulpix-tests/unit/stackOverflow.scala" , defaultOptions).expectFailure.checkRuns()
65
65
66
- @ Test def runOutRedirects : Unit =
66
+ @ test def runOutRedirects : Unit =
67
67
compileFile(" tests/vulpix-tests/unit/i2147.scala" , defaultOptions).expectFailure.checkRuns()
68
68
69
- @ Test def infiteNonRec : Unit =
69
+ @ test def infiniteNonRec : Unit =
70
70
compileFile(" tests/vulpix-tests/unit/infinite.scala" , defaultOptions).expectFailure.checkRuns()
71
71
72
- @ Test def infiteTailRec : Unit =
72
+ @ test def infiniteTailRec : Unit =
73
73
compileFile(" tests/vulpix-tests/unit/infiniteTail.scala" , defaultOptions).expectFailure.checkRuns()
74
74
75
- @ Test def infiniteAlloc : Unit =
75
+ @ test def infiniteAlloc : Unit =
76
76
compileFile(" tests/vulpix-tests/unit/infiniteAlloc.scala" , defaultOptions).expectFailure.checkRuns()
77
77
78
- @ Test def deadlock : Unit =
78
+ @ test def deadlock : Unit =
79
79
compileFile(" tests/vulpix-tests/unit/deadlock.scala" , defaultOptions).expectFailure.checkRuns()
80
80
81
- @ Test def badJava : Unit =
82
- try {
83
- compileFile(" tests/vulpix-tests/unit/BadJava.java" , defaultOptions).suppressAllOutput.checkCompile()
84
- fail()
85
- } catch {
86
- case ae : AssertionError => assertTrue(ae.getMessage.contains(" java compilation failed" ))
87
- }
81
+ @ test def badJava : Unit =
82
+ assertThrows[AssertionError ](_.getMessage.contains(" java compilation failed" )):
83
+ compileFile(" tests/vulpix-tests/unit/BadJava.java" , defaultOptions)
84
+ .suppressAllOutput
85
+ .checkCompile()
88
86
89
- @ Test def runTimeout : Unit = {
87
+ @ test def runTimeout : Unit =
90
88
val fileName = s " tests/vulpix-tests/unit/timeout.scala "
91
- try {
92
- compileFile(fileName, defaultOptions).checkRuns()
93
- fail()
94
- } catch {
95
- case ae : AssertionError =>
96
- val expect = """ (?m).*test '.+' timed out.*"""
97
- val actual = ae.getMessage.linesIterator.toList.last
98
- assert(actual.matches(expect), " actual = " + actual)
99
- }
100
- }
101
- }
102
-
103
-
104
- object VulpixUnitTests extends ParallelTesting {
89
+ val expect = """ (?m).*test '.+' timed out.*"""
90
+ assertThrows[AssertionError ](_.getMessage.linesIterator.toList.last.matches(expect)):
91
+ compileFile(fileName, defaultOptions)
92
+ .suppressAllOutput
93
+ .checkRuns()
94
+
95
+ object VulpixUnitTests extends ParallelTesting :
96
+ import scala .concurrent .duration .*
105
97
def maxDuration = 3 .seconds
106
98
def numberOfSlaves = 5
107
99
def safeMode = sys.env.get(" SAFEMODE" ).isDefined
@@ -110,6 +102,5 @@ object VulpixUnitTests extends ParallelTesting {
110
102
def updateCheckFiles : Boolean = false
111
103
def failedTests = None
112
104
113
- @ AfterClass
114
- def tearDown () = this .cleanup()
115
- }
105
+ @ tearDown
106
+ def tearDown () = cleanup()
0 commit comments