diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-04-15 14:51:18 +0200 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-04-15 14:51:18 +0200 |
commit | e4bea920b42eaa526a9e07ad001f17443d6abeba (patch) | |
tree | c786202cc9d0fa5b1a26dfd8e1154cacca7fbaf4 /test/disabled/jvm/concurrent-future.scala | |
parent | 23aa1a8d7b08b767f90657baf9bc13a355682671 (diff) | |
parent | 364dd41c3e0e33afe6c3ec6e0c04f1d345c4b6ca (diff) | |
download | scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.tar.gz scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.tar.bz2 scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.zip |
Merge branch 'master' of https://github.com/scala/scala into wip-sip14-fixes
Diffstat (limited to 'test/disabled/jvm/concurrent-future.scala')
-rw-r--r-- | test/disabled/jvm/concurrent-future.scala | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/test/disabled/jvm/concurrent-future.scala b/test/disabled/jvm/concurrent-future.scala new file mode 100644 index 0000000000..eda05428c8 --- /dev/null +++ b/test/disabled/jvm/concurrent-future.scala @@ -0,0 +1,122 @@ + + + +import scala.concurrent._ + + + +object Test extends App { + + def once(body: (() => Unit) => Unit) { + val sv = new SyncVar[Boolean] + body(() => sv put true) + sv.take() + } + + def output(num: Int, msg: String) { + println("test" + num + ": " + msg) + } + + def testOnSuccess(): Unit = once { + done => + val f = future { + output(1, "hai world") + } + f onSuccess { case _ => + output(1, "kthxbye") + done() + } + } + + def testOnSuccessWhenCompleted(): Unit = once { + done => + val f = future { + output(2, "hai world") + } + f onSuccess { case _ => + output(2, "awsum thx") + f onSuccess { case _ => + output(2, "kthxbye") + done() + } + } + } + + def testOnSuccessWhenFailed(): Unit = once { + done => + val f = future[Unit] { + output(3, "hai world") + done() + throw new Exception + } + f onSuccess { case _ => + output(3, "onoes") + } + } + + def testOnFailure(): Unit = once { + done => + val f = future[Unit] { + output(4, "hai world") + throw new Exception + } + f onSuccess { case _ => + output(4, "onoes") + done() + } + f onFailure { case _ => + output(4, "kthxbye") + done() + } + } + + def testOnFailureWhenSpecialThrowable(num: Int, cause: Throwable): Unit = once { + done => + val f = future[Unit] { + output(num, "hai world") + throw cause + } + f onSuccess { case _ => + output(num, "onoes") + done() + } + f onFailure { + case e: ExecutionException if (e.getCause == cause) => + output(num, "kthxbye") + done() + case _ => + output(num, "onoes") + done() + } + } + + // def testOnFailureWhenFutureTimeoutException(): Unit = once { + // done => + // val f = future[Unit] { + // output(8, "hai world") + // throw new FutureTimeoutException(null) + // } + // f onSuccess { case _ => + // output(8, "onoes") + // done() + // } + // f onFailure { + // case e: FutureTimeoutException => + // output(8, "im in yr loop") + // done() + // case other => + // output(8, "onoes: " + other) + // done() + // } + // } + + testOnSuccess() + testOnSuccessWhenCompleted() + testOnSuccessWhenFailed() + testOnFailure() + testOnFailureWhenSpecialThrowable(5, new Error) + testOnFailureWhenSpecialThrowable(6, new scala.util.control.ControlThrowable { }) + testOnFailureWhenSpecialThrowable(7, new InterruptedException) + // testOnFailureWhenFutureTimeoutException() + +} |