@@ -101,21 +101,26 @@ 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
+ sealed abstract class NegTestState
105
+ // Don't get confused, the neg test passes when compilation fails for at
106
+ // least one round (optionally checking the number of compiler errors and
107
+ // compiler console output)
108
+ case class CompFailed () extends NegTestState
109
+ // the neg test fails when all rounds return either of these:
110
+ case class CompFailedButWrongNErr (expected : String , found : String ) extends NegTestState
111
+ case class CompFailedButWrongDiff () extends NegTestState
112
+ case class CompSucceeded () extends NegTestState
108
113
109
114
def nerrIsOk (reason : String ) = {
110
115
import scala .util .matching .Regex
111
116
val nerrFinder = """ compilation failed with (\d\d+) errors""" .r
112
117
reason match {
113
118
case nerrFinder(found) =>
114
119
SFile (FileOps (testFile) changeExtension " nerr" ).safeSlurp match {
115
- case Some (exp) if (exp != found) => FailedWithWrongNErr (exp, found)
116
- case _ => FoundFailed
120
+ case Some (exp) if (exp != found) => CompFailedButWrongNErr (exp, found)
121
+ case _ => CompFailed
117
122
}
118
- case _ => FoundFailed
123
+ case _ => CompFailed
119
124
}
120
125
}
121
126
@@ -129,19 +134,31 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
129
134
130
135
val failureStates = compFailingRounds.map({ case (result, _) => result match {
131
136
// 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
137
+ case Crash (_, t, _) if ! checkFile.canRead || ! t.isInstanceOf [FatalError ] => CompSucceeded
138
+ case Fail (_, reason, _) => if (diffIsOk) nerrIsOk(reason) else CompFailedButWrongDiff
139
+ case _ => if (diffIsOk) CompFailed else CompFailedButWrongDiff
135
140
}})
136
141
137
- if (failureStates.exists({ case FoundFailed => true ; case _ => false })) {
142
+ if (failureStates.exists({ case CompFailed => true ; case _ => false })) {
138
143
true
139
144
} else {
140
145
val existsNerr = failureStates.exists({
141
- case FailedWithWrongNErr (exp, found) => nextTestActionFailing(s " wrong number of compilation errors, expected: $exp, found: $found" ); true
146
+ case CompFailedButWrongNErr (exp, found) => nextTestActionFailing(s " wrong number of compilation errors, expected: $exp, found: $found" ); true
142
147
case _ => false
143
148
})
144
- if (existsNerr) false else nextTestActionFailing(" expected compilation failure" )
149
+ if (existsNerr) {
150
+ false
151
+ } else {
152
+ val existsDiff = failureStates.exists({
153
+ case CompFailedButWrongDiff () => nextTestActionFailing(s " output differs " ); true
154
+ case _ => false
155
+ })
156
+ if (existsDiff) {
157
+ false
158
+ } else {
159
+ nextTestActionFailing(" expected compilation failure" )
160
+ }
161
+ }
145
162
}
146
163
}
147
164
}
0 commit comments