diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-07-06 16:02:35 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-07-06 16:02:35 +1000 |
commit | d7914c3879cbe832b640c07a24ee6941fa545928 (patch) | |
tree | 4522b6199fc4316e4c15522733662dc590f3679e /src/test/scala/scala | |
parent | 93dab7a6fe81227953d087813d5cab0d0634b9f2 (diff) | |
parent | f1d9667189ebad285553e912a2eac4a64093c8bf (diff) | |
download | scala-async-d7914c3879cbe832b640c07a24ee6941fa545928.tar.gz scala-async-d7914c3879cbe832b640c07a24ee6941fa545928.tar.bz2 scala-async-d7914c3879cbe832b640c07a24ee6941fa545928.zip |
Merge pull request #113 from retronym/backport/104
[backport] Avoid masking real errors with NotImplemented awaiting Future[Nothing]
Diffstat (limited to 'src/test/scala/scala')
-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 17d33af..09d01c1 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 + } } |