blob: 7aaf3ed9b953e45452f5b370c82485b2e6f78ff7 [file]
// LANGUAGE: +JsIntegerDivisionCheck
fun expectArithmeticException(f: () -> Unit): Boolean {
try {
f()
} catch (e: ArithmeticException) {
return true
}
return false
}
fun box(): String {
if (!expectArithmeticException { 1 / 0 })
return "fail: 1 / 0 didn't throw exception"
if (!expectArithmeticException { 1 * 2 / 0 })
return "fail: 1 * 2 / 0 didn't throw exception"
if (!expectArithmeticException { 1 * (2 / 0) })
return "fail: 1 * (2 / 0) didn't throw exception"
return "OK"
}