Skip to content

Commit 07384ca

Browse files
committed
Address reviews for #1966
1 parent f8c3993 commit 07384ca

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ import org.junit.Assert._
1111

1212
trait ErrorMessagesTest extends DottyTest {
1313

14+
ctx = freshReporter(ctx)
15+
16+
private def freshReporter(ctx: Context) =
17+
ctx.fresh.setReporter(new CapturingReporter)
18+
19+
1420
class Report(messages: List[Message], ictx: Context) {
1521
def expect(f: (Context, List[Message]) => Unit): Unit = {
1622
f(ictx, messages)
1723
}
1824

19-
def expectNoErrors: Unit = this.isInstanceOf[FailedReport]
25+
def expectNoErrors: Unit =
26+
assert(this.isInstanceOf[EmptyReport], "errors found when not expected")
2027
}
2128

22-
class FailedReport extends Report(Nil, null) {
29+
class EmptyReport extends Report(Nil, null) {
2330
override def expect(f: (Context, List[Message]) => Unit) =
2431
fail("""|
2532
|Couldn't capture errors from compiled sources, this can happen if
@@ -38,7 +45,7 @@ trait ErrorMessagesTest extends DottyTest {
3845

3946
def toReport: Report =
4047
if (capturedContext eq null)
41-
new FailedReport
48+
new EmptyReport
4249
else {
4350
val xs = buffer.reverse.toList
4451
buffer.clear()
@@ -50,19 +57,14 @@ trait ErrorMessagesTest extends DottyTest {
5057
}
5158
}
5259

53-
ctx = freshReporter(ctx)
54-
55-
private def freshReporter(ctx: Context) =
56-
ctx.fresh.setReporter(new CapturingReporter)
57-
5860
def checkMessages(source: String): Report = {
5961
checkCompile("frontend", source) { (_,ictx) => () }
6062
val rep = ctx.reporter.asInstanceOf[CapturingReporter].toReport
6163
ctx = freshReporter(ctx)
6264
rep
6365
}
6466

65-
def messageCount(expected: Int, messages: List[Message]): Unit =
67+
def assertMessageCount(expected: Int, messages: List[Message]): Unit =
6668
assertEquals(
6769
expected,
6870
messages.length

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
2828
val defn = ictx.definitions
2929

3030
// Assert that we only got one error message
31-
messageCount(1, messages)
31+
assertMessageCount(1, messages)
3232

3333
// Pattern match out the expected error
3434
val TypeMismatch(found, expected, _, _) :: Nil = messages

0 commit comments

Comments
 (0)