diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-10 15:18:53 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-10 15:18:53 +0100 |
commit | 93d3f1201e00c0436d2b2bcd3445ba218e0e1a89 (patch) | |
tree | 562b3c4090abce6500da4f8c7ff4250f40e212b1 /test/dotty | |
parent | 28c2e04dd33b6389a44460f977a97b8691265994 (diff) | |
download | dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.tar.gz dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.tar.bz2 dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.zip |
Make sure messages are lazily evaluated until `report` in `Reporter`
Diffstat (limited to 'test/dotty')
-rw-r--r-- | test/dotty/tools/dotc/reporting/TestMessageLaziness.scala | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala b/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala new file mode 100644 index 000000000..fe85edda6 --- /dev/null +++ b/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala @@ -0,0 +1,37 @@ +package dotty.tools +package dotc +package reporting + +import org.junit.Assert._ +import org.junit.Test + +import core.Contexts._ + +import test.DottyTest + +import diagnostic.{ Message, MessageContainer, ExtendMessage } + +class TestMessageLaziness extends DottyTest { + ctx = ctx.fresh.setReporter(new NonchalantReporter) + + class NonchalantReporter(implicit ctx: Context) extends Reporter + with UniqueMessagePositions with HideNonSensicalMessages { + def doReport(d: MessageContainer)(implicit ctx: Context) = ??? + + override def report(d: => MessageContainer)(implicit ctx: Context) = () + } + + case class LazyError() extends Message(1000) { + throw new Error("Didn't stay lazy.") + + val kind = "Test" + val msg = "Please don't blow up" + val explanation = "" + } + + @Test def assureLazy = + ctx.error(LazyError()) + + @Test def assureLazyExtendMessage = + ctx.strictWarning(LazyError()) +} |