summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-03-31 21:23:00 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-03-31 21:23:00 +1000
commit5d5de4d2cd84cbf02dfc2843a72f1996ae758988 (patch)
treec13373324e57a62079047d11dade9b411fff7788
parent8859afbb2a4319da007918f7ea80036d0dc90a12 (diff)
downloadscala-5d5de4d2cd84cbf02dfc2843a72f1996ae758988.tar.gz
scala-5d5de4d2cd84cbf02dfc2843a72f1996ae758988.tar.bz2
scala-5d5de4d2cd84cbf02dfc2843a72f1996ae758988.zip
[backport] 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.
-rw-r--r--test/files/jvm/t8689.scala9
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
+}