diff options
author | Philipp Haller <hallerp@gmail.com> | 2011-12-13 09:03:30 +0100 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2011-12-13 09:03:30 +0100 |
commit | 5fcd1e067767b56ae323b0a37b169bf4e0a937b6 (patch) | |
tree | 6bb4110e5b26abf028d6e174694d9edea78e44d7 /test/files/jvm | |
parent | 9a04d0bea379c3fa12227493fddd0bffde9a569c (diff) | |
download | scala-5fcd1e067767b56ae323b0a37b169bf4e0a937b6.tar.gz scala-5fcd1e067767b56ae323b0a37b169bf4e0a937b6.tar.bz2 scala-5fcd1e067767b56ae323b0a37b169bf4e0a937b6.zip |
Fix default.ExecutionContextImpl.promise. Add promise test.
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index e1b8d2763c..705675ae43 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -3,6 +3,7 @@ import scala.concurrent.{ Future, + Promise, TimeoutException, SyncVar, ExecutionException @@ -14,6 +15,8 @@ trait TestBase { def future[T](body: =>T): Future[T] + def promise[T]: Promise[T] + def once(body: (() => Unit) => Unit) { val sv = new SyncVar[Boolean] body(() => sv put true) @@ -141,7 +144,25 @@ trait FutureProjections extends TestBase { trait Promises extends TestBase { - + + def testSuccess(): Unit = once { + done => + val p = promise[Int] + val f = p.future + + f.onSuccess { x => + done() + assert(x == 5) + } onFailure { case any => + done() + assert(false) + } + + p.success(5) + } + + testSuccess() + } @@ -161,6 +182,8 @@ with Exceptions def future[T](body: =>T) = scala.concurrent.future(body) + def promise[T] = scala.concurrent.promise[T] + } |