public static assertThrows<TYPE extends Exception = Exception, RESULT = Void>(notnull block as () -> RESULT) as Void
Verifies that invoking a function or lambda without parameters raises an exception.
When TYPE is omitted, any exception type is accepted. When TYPE is provided, the raised exception must match it. The callable's return type RESULT is inferred; its result is ignored. An evaluated expression is not a callable and is rejected at compilation.
| Parameter | Description |
|---|---|
block | The parameterless function or lambda to invoke once. |
import klyn.unittest
Assert.assertThrows(lambda (): Int("abc"))
invalidCodeUnit = -1
Assert.assertThrows<TypeError>(lambda (): CodeUnit(invalidCodeUnit))