diff --git a/libraries/stdlib/src/kotlin/test/Test.kt b/libraries/stdlib/src/kotlin/test/Test.kt index e76a0710c9a..446757e0a72 100644 --- a/libraries/stdlib/src/kotlin/test/Test.kt +++ b/libraries/stdlib/src/kotlin/test/Test.kt @@ -81,14 +81,15 @@ public inline fun expect(expected: T, message: String, block: ()-> T) { /** Asserts that given function block fails by throwing an exception */ public fun fails(block: ()-> Unit): Throwable? { + var thrown : Throwable? = null try { block() - asserter.fail("Expected an exception to be thrown") - return null } catch (e: Throwable) { - //println("Caught expected exception: $e") - return e + thrown = e } + if (thrown == null) + asserter.fail("Expected an exception to be thrown") + return thrown } /**