aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-10 15:35:13 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-02-10 15:42:13 +0100
commit07384caa0b6c732e180f172402023ea47f3e31ae (patch)
treee396948812d6bcc7ff6e626978218ca440964c47 /compiler/test/dotty/tools/dotc/reporting
parentf8c3993ca6e78edf2f9bf5842bce78c028578081 (diff)
downloaddotty-07384caa0b6c732e180f172402023ea47f3e31ae.tar.gz
dotty-07384caa0b6c732e180f172402023ea47f3e31ae.tar.bz2
dotty-07384caa0b6c732e180f172402023ea47f3e31ae.zip
Address reviews for #1966
Diffstat (limited to 'compiler/test/dotty/tools/dotc/reporting')
-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