This is used for unit testing: ``` inline fun <...
# announcements
z
This is used for unit testing:
Copy code
inline fun <reified T: Throwable> assertThrows(function: () -> Unit): T {
    try {
        function()
    } catch(throwable: Throwable) {
        when (throwable) {
            is T -> return throwable
            else -> throw Exception("Unexpected exception thrown.")
        }
    }

    throw Exception("Exception was expected but nothing thrown.")
}