From b31098caac2aa63e8f87720956ead0bb774e2799 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 31 Mar 2015 09:35:11 +1000 Subject: 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. --- test/files/jvm/t8689.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test') 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 +} -- cgit v1.2.3