diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-03-31 09:35:11 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-03-31 13:58:47 +1000 |
commit | b31098caac2aa63e8f87720956ead0bb774e2799 (patch) | |
tree | 17bb597b6d76f065d2bcfe759c3aa5715576f57d /test | |
parent | 955eb2170e1291500813e6bec76a9f0e1e3bad50 (diff) | |
download | scala-b31098caac2aa63e8f87720956ead0bb774e2799.tar.gz scala-b31098caac2aa63e8f87720956ead0bb774e2799.tar.bz2 scala-b31098caac2aa63e8f87720956ead0bb774e2799.zip |
SI-8689 Make a Future test case determistic
As discussed:
https://groups.google.com/forum/#!topic/scala-internals/m8I_3GQR4vQ
We need to ensure a happens-before relationship between the callback
that prints "success" and the end of the main method.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/t8689.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/files/jvm/t8689.scala b/test/files/jvm/t8689.scala index ef43a1df63..3ee20d711a 100644 --- a/test/files/jvm/t8689.scala +++ b/test/files/jvm/t8689.scala @@ -4,10 +4,15 @@ object Test { import ExecutionContext.Implicits.global val source1 = Promise[Int]() val source2 = Promise[Int]() + val done = Promise[Unit]() source2.completeWith(source1.future).future.onComplete { - case _ => print("success") + case _ => + print("success") + done.success(()) } source2.tryFailure(new TimeoutException) source1.success(123) + import duration._ + Await.result(done.future, 120.seconds) } -}
\ No newline at end of file +} |