Skip to content

Commit 3d20e9d

Browse files
committed
Address reviews for #1966
1 parent f8c3993 commit 3d20e9d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ 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 = assert(this.isInstanceOf[EmptyReport])
2026
}
2127

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

3945
def toReport: Report =
4046
if (capturedContext eq null)
41-
new FailedReport
47+
new EmptyReport
4248
else {
4349
val xs = buffer.reverse.toList
4450
buffer.clear()
@@ -50,19 +56,14 @@ trait ErrorMessagesTest extends DottyTest {
5056
}
5157
}
5258

53-
ctx = freshReporter(ctx)
54-
55-
private def freshReporter(ctx: Context) =
56-
ctx.fresh.setReporter(new CapturingReporter)
57-
5859
def checkMessages(source: String): Report = {
5960
checkCompile("frontend", source) { (_,ictx) => () }
6061
val rep = ctx.reporter.asInstanceOf[CapturingReporter].toReport
6162
ctx = freshReporter(ctx)
6263
rep
6364
}
6465

65-
def messageCount(expected: Int, messages: List[Message]): Unit =
66+
def assertMessageCount(expected: Int, messages: List[Message]): Unit =
6667
assertEquals(
6768
expected,
6869
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)