diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-11 12:00:15 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-11 12:00:15 -0700 |
commit | ea651e6fe187920d207aa5fe3c645d294e72e627 (patch) | |
tree | b1f8a44115d5bad5e298f31f6123993088240056 /test/files/jvm/scala-concurrent-tck.scala | |
parent | ad9b6bcdbcd48566f0b7f03b29c9252fcebc3926 (diff) | |
parent | ad6c261eafbe72e014d005d0452c8a628a07f123 (diff) | |
download | scala-ea651e6fe187920d207aa5fe3c645d294e72e627.tar.gz scala-ea651e6fe187920d207aa5fe3c645d294e72e627.tar.bz2 scala-ea651e6fe187920d207aa5fe3c645d294e72e627.zip |
Merge pull request #1279 from rkuhn/fix-duration-usage
fix usage of Duration in Promise impl
Diffstat (limited to 'test/files/jvm/scala-concurrent-tck.scala')
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index ffb5608fd2..0e76b711de 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -11,6 +11,8 @@ import scala.concurrent.{ import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } import scala.concurrent.util.Duration +import scala.reflect.{ classTag, ClassTag } +import scala.tools.partest.TestUtil.intercept trait TestBase { @@ -19,7 +21,7 @@ trait TestBase { body(() => sv put true) sv.take(2000) } - + // def assert(cond: => Boolean) { // try { // Predef.assert(cond) @@ -663,6 +665,29 @@ trait FutureProjections extends TestBase { case nsee: NoSuchElementException => done() } } + + def testAwaitPositiveDuration(): Unit = once { done => + val p = Promise[Int]() + val f = p.future + future { + intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) } + p.success(0) + Await.ready(f, Duration.Zero) + Await.ready(f, Duration(500, "ms")) + Await.ready(f, Duration.Inf) + done() + } onFailure { case x => throw x } + } + + def testAwaitNegativeDuration(): Unit = once { done => + val f = Promise().future + future { + intercept[TimeoutException] { Await.ready(f, Duration.Zero) } + intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) } + intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) } + done() + } onFailure { case x => throw x } + } testFailedFailureOnComplete() testFailedFailureOnSuccess() @@ -670,6 +695,8 @@ trait FutureProjections extends TestBase { testFailedSuccessOnFailure() testFailedFailureAwait() testFailedSuccessAwait() + testAwaitPositiveDuration() + testAwaitNegativeDuration() } |