summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/testing
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-12-21 23:32:14 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-02-09 13:40:46 -0800
commit51800ce0e83daeadf68a90bef4d64734e4721f3a (patch)
tree7d2dff0ea474c3c0dfa727d9b666f5b468b1c63f /test/junit/scala/tools/testing
parent9d09247f13b8a77c1b3a2bb5d44510b7cec38dce (diff)
downloadscala-51800ce0e83daeadf68a90bef4d64734e4721f3a.tar.gz
scala-51800ce0e83daeadf68a90bef4d64734e4721f3a.tar.bz2
scala-51800ce0e83daeadf68a90bef4d64734e4721f3a.zip
SI-8818 FreshName extractor forgives suffix
The test is corrected (inverted) and the extractor is made more succinct. Succinctness isn't enforced by the test, but I checked it manually.
Diffstat (limited to 'test/junit/scala/tools/testing')
-rw-r--r--test/junit/scala/tools/testing/AssertUtil.scala21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala
index d29f9a473f..d798f2e53e 100644
--- a/test/junit/scala/tools/testing/AssertUtil.scala
+++ b/test/junit/scala/tools/testing/AssertUtil.scala
@@ -36,21 +36,20 @@ object AssertUtil {
}
}
- /** Check if throwable T (or a subclass) was thrown during evaluation of f, and that its message
- * satisfies the `checkMessage` predicate. If any other exception will be re-thrown.
+ /** Check that throwable T (or a subclass) was thrown during evaluation of `body`,
+ * and that its message satisfies the `checkMessage` predicate.
+ * Any other exception is propagated.
*/
- def assertThrows[T <: Throwable](f: => Any,
+ def assertThrows[T <: Throwable](body: => Any,
checkMessage: String => Boolean = s => true)
(implicit manifest: Manifest[T]): Unit = {
- try f
- catch {
- case e: Throwable if checkMessage(e.getMessage) =>
- val clazz = manifest.runtimeClass
- if (!clazz.isAssignableFrom(e.getClass))
- throw e
- else return
+ try {
+ body
+ fail("Expression did not throw!")
+ } catch {
+ case e: Throwable if (manifest.runtimeClass isAssignableFrom e.getClass) &&
+ checkMessage(e.getMessage) =>
}
- fail("Expression did not throw!")
}
/** JUnit-style assertion for `IterableLike.sameElements`.