Skip to content

Commit 1fcdb69

Browse files
committed
Partest rename NegStates
1 parent a4e58e2 commit 1fcdb69

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

test/dotty/partest/DottyPartestRunner.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,23 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
101101
import TestState.{ Crash, Fail }
102102
import scala.reflect.internal.FatalError
103103

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
108110

109111
def nerrIsOk(reason: String) = {
110112
import scala.util.matching.Regex
111113
val nerrFinder = """compilation failed with (\d\d+) errors""".r
112114
reason match {
113115
case nerrFinder(found) =>
114116
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
117119
}
118-
case _ => FoundFailed
120+
case _ => CompFailed
119121
}
120122
}
121123

@@ -129,16 +131,16 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
129131

130132
val failureStates = compFailingRounds.map({ case (result, _) => result match {
131133
// 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
135137
}})
136138

137-
if (failureStates.exists({ case FoundFailed => true; case _ => false })) {
139+
if (failureStates.exists({ case CompFailed => true; case _ => false })) {
138140
true
139141
} else {
140142
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
142144
case _ => false
143145
})
144146
if (existsNerr) false else nextTestActionFailing("expected compilation failure")

0 commit comments

Comments
 (0)