From 0b5ab2112889104cd682a7af8b2feab113bef99c Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 11:41:26 +0200 Subject: [PATCH] Adding yet another CPS test --- .../test/scala/akka/dispatch/FutureSpec.scala | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 9140cd236a..3749cc4bbd 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -500,7 +500,29 @@ class FutureSpec extends JUnitSuite { assert(result2.get === 50) } - @Test def futureDataFlowShouldEmulateBlocking { + @Test def futureDataFlowShouldEmulateBlocking1 { + import Future.flow + + val one, two = new DefaultCompletableFuture[Int](1000 * 60) + val simpleResult = flow { + one() + two() + } + + assert(List(one, two, simpleResult).forall(_.isCompleted == false)) + + one << 1 + + assert(one.isCompleted) + assert(List(two, simpleResult).forall(_.isCompleted == false)) + + two << 9 + + assert(List(one, two).forall(_.isCompleted == true)) + assert(simpleResult.await.result.get === 10) + + } + + @Test def futureDataFlowShouldEmulateBlocking2 { import Future.flow val x1, x2, y1, y2 = new DefaultCompletableFuture[Int](1000 * 60) val lx, ly, lz = new StandardLatch