diff options
author | Roland <rk@rkuhn.info> | 2012-09-11 17:58:35 +0200 |
---|---|---|
committer | Roland <rk@rkuhn.info> | 2012-09-11 17:58:35 +0200 |
commit | ad6c261eafbe72e014d005d0452c8a628a07f123 (patch) | |
tree | 9d96d5c18f44ea1bb6305d8b689019864f90a3b4 /src/partest | |
parent | 3767a6a83efc74d34e9025f798eeb2a043e6df8d (diff) | |
download | scala-ad6c261eafbe72e014d005d0452c8a628a07f123.tar.gz scala-ad6c261eafbe72e014d005d0452c8a628a07f123.tar.bz2 scala-ad6c261eafbe72e014d005d0452c8a628a07f123.zip |
improve docs and Promise impl
- scaladoc the exceptions thrown by Await.* and Awaitable.*
- move intercept[Exception] into partest’s TestUtil object
- improve Promise.tryAwait implementation following Viktor’s comments
and make use of Deadline to avoid calling System.nanoTime too often
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/TestUtil.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index b86a8e2c7f..146e6fc69f 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -1,5 +1,7 @@ package scala.tools.partest +import reflect.{ classTag, ClassTag } + trait TestUtil { /** Given function and block of code, evaluates code block, * calls function with nanoseconds elapsed, and returns block result. @@ -29,8 +31,16 @@ trait TestUtil { assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) } + + def intercept[T <: Exception : ClassTag](code: => Unit): Unit = + try { + code + assert(false, "did not throw " + classTag[T]) + } catch { + case ex: Exception if classTag[T].runtimeClass isInstance ex => + } } object TestUtil extends TestUtil { -}
\ No newline at end of file +} |