zoltu
06/24/2016, 8:23 PMinline 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.")
}