stdlib: Enable assertFailsWith function

The function was disabled due to an issue with catch serialization.
Now the issue is fixed and the function can be re-enabled.
This commit is contained in:
Ilya Matveev
2017-12-18 15:14:11 +07:00
committed by ilmat192
parent bf67bc38fc
commit 92e666f023
3 changed files with 44 additions and 68 deletions
-19
View File
@@ -1,24 +1,5 @@
package kotlin.test
// TODO: Remove it when such method from library is available.
/** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, block: () -> Unit): T {
try {
block()
} catch (e: Throwable) {
if (e is T) {
@Suppress("UNCHECKED_CAST")
return e
}
@Suppress("INVISIBLE_MEMBER")
fail(message + ". Expected an exception of type //TODO: add type!// to be thrown, but was $e")
}
@Suppress("INVISIBLE_MEMBER")
fail(message + ". Expected an exception of type //TODO: add type!// to be thrown, but was completed successfully.")
}
@Suppress("UNUSED_PARAMETER")
public fun assertTypeEquals(expected: Any?, actual: Any?) {
//TODO: find analogue