Skip to content

Commit 6cf2c04

Browse files
authored
Merge pull request scala#5604 from sjrd/scalajs-friendly-assertthrows
Use ClassTag instead of Manifest in AssertUtil.assertThrows.
2 parents bf54f1f + 97e8ee7 commit 6cf2c04

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/junit/scala/tools/testing/AssertUtil.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package testing
33

44
import org.junit.Assert
55
import Assert._
6+
import scala.reflect.ClassTag
67
import scala.runtime.ScalaRunTime.stringOf
78
import scala.collection.{ GenIterable, IterableLike }
89
import scala.collection.JavaConverters._
@@ -40,15 +41,13 @@ object AssertUtil {
4041
* and that its message satisfies the `checkMessage` predicate.
4142
* Any other exception is propagated.
4243
*/
43-
def assertThrows[T <: Throwable](body: => Any,
44-
checkMessage: String => Boolean = s => true)
45-
(implicit manifest: Manifest[T]): Unit = {
44+
def assertThrows[T <: Throwable: ClassTag](body: => Any,
45+
checkMessage: String => Boolean = s => true): Unit = {
4646
try {
4747
body
4848
fail("Expression did not throw!")
4949
} catch {
50-
case e: Throwable if (manifest.runtimeClass isAssignableFrom e.getClass) &&
51-
checkMessage(e.getMessage) =>
50+
case e: T if checkMessage(e.getMessage) =>
5251
}
5352
}
5453

0 commit comments

Comments
 (0)