From 87370ba3bdb3ebf4cd7dec1065bb7d6c9bddcf72 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Wed, 7 Mar 2012 13:14:49 -0500 Subject: [PATCH] Generalize test exception catching to Throwable so that you can test for RuntimeExceptions. --- libraries/stdlib/src/test/Test.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/test/Test.kt b/libraries/stdlib/src/test/Test.kt index 310cf5cf33f..e4af2cc5bb1 100644 --- a/libraries/stdlib/src/test/Test.kt +++ b/libraries/stdlib/src/test/Test.kt @@ -84,19 +84,19 @@ inline fun expect(expected: T, message: String, block: ()-> T) { } /** Asserts that given function block fails by throwing an exception */ -fun fails(block: ()-> Unit): Exception? { +fun fails(block: ()-> Unit): Throwable? { try { block() asserter().fail("Expected an exception to be thrown") return null - } catch (e: Exception) { + } catch (e: Throwable) { println("Caught excepted exception: $e") return e } } /** Asserts that a block fails with a specific exception being thrown */ -fun failsWith(block: ()-> Unit) { +fun failsWith(block: ()-> Unit) { try { block() asserter().fail("Expected an exception to be thrown")