@@ -101,21 +101,23 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
101
101
import TestState .{ Crash , Fail }
102
102
import scala .reflect .internal .FatalError
103
103
104
- sealed abstract class State
105
- case class FoundFailed () extends State
106
- case class FailedWithWrongNErr (expected : String , found : String ) extends State
107
- case class NoneFailed () extends State
104
+ // Don't get confused, a neg test passes when compilation fails (optionally
105
+ // checking the number of compiler errors)
106
+ sealed abstract class NegTestState
107
+ case class CompFailed () extends NegTestState
108
+ case class CompFailedWrongNErr (expected : String , found : String ) extends NegTestState
109
+ case class CompSucceeded () extends NegTestState
108
110
109
111
def nerrIsOk (reason : String ) = {
110
112
import scala .util .matching .Regex
111
113
val nerrFinder = """ compilation failed with (\d\d+) errors""" .r
112
114
reason match {
113
115
case nerrFinder(found) =>
114
116
SFile (FileOps (testFile) changeExtension " nerr" ).safeSlurp match {
115
- case Some (exp) if (exp != found) => FailedWithWrongNErr (exp, found)
116
- case _ => FoundFailed
117
+ case Some (exp) if (exp != found) => CompFailedWrongNErr (exp, found)
118
+ case _ => CompFailed
117
119
}
118
- case _ => FoundFailed
120
+ case _ => CompFailed
119
121
}
120
122
}
121
123
@@ -129,16 +131,16 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
129
131
130
132
val failureStates = compFailingRounds.map({ case (result, _) => result match {
131
133
// or, OK, we'll let you crash the compiler with a FatalError if you supply a check file
132
- case Crash (_, t, _) if ! checkFile.canRead || ! t.isInstanceOf [FatalError ] => NoneFailed
133
- case Fail (_, reason, _) => if (diffIsOk) nerrIsOk(reason) else NoneFailed
134
- case _ => if (diffIsOk) FoundFailed else NoneFailed
134
+ case Crash (_, t, _) if ! checkFile.canRead || ! t.isInstanceOf [FatalError ] => CompSucceeded
135
+ case Fail (_, reason, _) => if (diffIsOk) nerrIsOk(reason) else CompSucceeded
136
+ case _ => if (diffIsOk) CompFailed else CompSucceeded
135
137
}})
136
138
137
- if (failureStates.exists({ case FoundFailed => true ; case _ => false })) {
139
+ if (failureStates.exists({ case CompFailed => true ; case _ => false })) {
138
140
true
139
141
} else {
140
142
val existsNerr = failureStates.exists({
141
- case FailedWithWrongNErr (exp, found) => nextTestActionFailing(s " wrong number of compilation errors, expected: $exp, found: $found" ); true
143
+ case CompFailedWrongNErr (exp, found) => nextTestActionFailing(s " wrong number of compilation errors, expected: $exp, found: $found" ); true
142
144
case _ => false
143
145
})
144
146
if (existsNerr) false else nextTestActionFailing(" expected compilation failure" )
0 commit comments