summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoland <rk@rkuhn.info>2012-09-11 20:37:43 +0200
committerRoland <rk@rkuhn.info>2012-09-11 20:39:24 +0200
commit4a476e775fe7d3a126a42a5127c31e09b9117393 (patch)
treeaac9c496fa87b5e4b9b5c47b944895a9db0e6399 /src
parentccf734acb7a6d0ea21cd44e5f0fc378a6804825d (diff)
downloadscala-4a476e775fe7d3a126a42a5127c31e09b9117393.tar.gz
scala-4a476e775fe7d3a126a42a5127c31e09b9117393.tar.bz2
scala-4a476e775fe7d3a126a42a5127c31e09b9117393.zip
two more minor cleanups to Duration
- copy partest TestUtil.intercept change from PR 1279 branch - add comment on non-obvious match cases
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/concurrent/util/Duration.scala4
-rw-r--r--src/partest/scala/tools/partest/TestUtil.scala12
2 files changed, 13 insertions, 3 deletions
diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala
index 6d44c93bc2..8fd47630cb 100644
--- a/src/library/scala/concurrent/util/Duration.scala
+++ b/src/library/scala/concurrent/util/Duration.scala
@@ -306,8 +306,8 @@ object Duration {
val Inf: Infinite = new Infinite {
override def toString = "Duration.Inf"
def compare(other: Duration) = other match {
- case x if x eq Undefined => -1
- case x if x eq this => 0
+ case x if x eq Undefined => -1 // Undefined != Undefined
+ case x if x eq this => 0 // `case Inf` will include null checks in the byte code
case _ => 1
}
def unary_- : Duration = MinusInf
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
+}