Fix fails() assertion which was silently swallowing exceptions.

This commit is contained in:
Ilya Ryzhenkov
2014-07-15 20:56:23 +04:00
committed by Evgeny Gerashchenko
parent 0b7699b844
commit d4db837dec
+5 -4
View File
@@ -81,14 +81,15 @@ public inline fun <T> 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
}
/**