initial commit (moved from divan)
This commit is contained in:
commit
770555024f
56 files changed
+2745
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import kotlin.test.fail
|
||||
|
||||
inline fun <reified T: Throwable>assertThrows(f: ()->Unit): T {
|
||||
val name = T::class.simpleName
|
||||
try {
|
||||
f()
|
||||
fail("expected to throw $name but threw nothing")
|
||||
}
|
||||
catch(x: Throwable) {
|
||||
if( x is T ) return x
|
||||
fail("expected to throw $name but instead threw ${x::class.simpleName}: $x")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user