aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala20
-rw-r--r--compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala2
2 files changed, 12 insertions, 10 deletions
diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala
index 807e3a40a..67a09b9bf 100644
--- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala
+++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala
@@ -11,15 +11,22 @@ import org.junit.Assert._
trait ErrorMessagesTest extends DottyTest {
+ ctx = freshReporter(ctx)
+
+ private def freshReporter(ctx: Context) =
+ ctx.fresh.setReporter(new CapturingReporter)
+
+
class Report(messages: List[Message], ictx: Context) {
def expect(f: (Context, List[Message]) => Unit): Unit = {
f(ictx, messages)
}
- def expectNoErrors: Unit = this.isInstanceOf[FailedReport]
+ def expectNoErrors: Unit =
+ assert(this.isInstanceOf[EmptyReport], "errors found when not expected")
}
- class FailedReport extends Report(Nil, null) {
+ class EmptyReport extends Report(Nil, null) {
override def expect(f: (Context, List[Message]) => Unit) =
fail("""|
|Couldn't capture errors from compiled sources, this can happen if
@@ -38,7 +45,7 @@ trait ErrorMessagesTest extends DottyTest {
def toReport: Report =
if (capturedContext eq null)
- new FailedReport
+ new EmptyReport
else {
val xs = buffer.reverse.toList
buffer.clear()
@@ -50,11 +57,6 @@ trait ErrorMessagesTest extends DottyTest {
}
}
- ctx = freshReporter(ctx)
-
- private def freshReporter(ctx: Context) =
- ctx.fresh.setReporter(new CapturingReporter)
-
def checkMessages(source: String): Report = {
checkCompile("frontend", source) { (_,ictx) => () }
val rep = ctx.reporter.asInstanceOf[CapturingReporter].toReport
@@ -62,7 +64,7 @@ trait ErrorMessagesTest extends DottyTest {
rep
}
- def messageCount(expected: Int, messages: List[Message]): Unit =
+ def assertMessageCount(expected: Int, messages: List[Message]): Unit =
assertEquals(
expected,
messages.length
diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
index eb7b944b1..59391cf90 100644
--- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
+++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
@@ -28,7 +28,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
val defn = ictx.definitions
// Assert that we only got one error message
- messageCount(1, messages)
+ assertMessageCount(1, messages)
// Pattern match out the expected error
val TypeMismatch(found, expected, _, _) :: Nil = messages