diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-07-06 15:06:49 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-07-06 15:06:49 +1000 |
commit | 6353443a0adec384172c38efac3bc96b9d2cbad2 (patch) | |
tree | 3a5944fd737d367072ae766dddaf39fcf331f50e /src/test/scala/scala/async | |
parent | 720153706dcb0d311f4591b30198502d9980372d (diff) | |
download | scala-async-6353443a0adec384172c38efac3bc96b9d2cbad2.tar.gz scala-async-6353443a0adec384172c38efac3bc96b9d2cbad2.tar.bz2 scala-async-6353443a0adec384172c38efac3bc96b9d2cbad2.zip |
Avoid masking real errors with NotImplemented awaiting Future[Nothing]
This commit disabled live variable analysis for intermediate values of type Nothing.
Fixes #104
Diffstat (limited to 'src/test/scala/scala/async')
-rw-r--r-- | src/test/scala/scala/async/run/live/LiveVariablesSpec.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala index 30646a6..01cf911 100644 --- a/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala +++ b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala @@ -263,4 +263,30 @@ class LiveVariablesSpec { } baz() } + + // https://github.com/scala/async/issues/104 + @Test def dontNullOutVarsOfTypeNothing_t104(): Unit = { + implicit val ec: scala.concurrent.ExecutionContext = null + import scala.async.Async._ + import scala.concurrent.duration.Duration + import scala.concurrent.{Await, Future} + import scala.concurrent.ExecutionContext.Implicits.global + def errorGenerator(randomNum: Double) = { + Future { + if (randomNum < 0) { + throw new IllegalStateException("Random number was too low!") + } else { + throw new IllegalStateException("Random number was too high!") + } + } + } + def randomTimesTwo = async { + val num = _root_.scala.math.random + if (num < 0 || num > 1) { + await(errorGenerator(num)) + } + num * 2 + } + Await.result(randomTimesTwo, TestLatch.DefaultTimeout) // was: NotImplementedError + } } |