Files
kotlin-fork/backend.native/tests/external/codegen/blackbox/controlStructures/tryCatchInExpressions/tryAndContinue.kt
T
Ilya Matveev 1b553ebfaf backend/tests: Add blackbox tests from Kotlin JVM
Added tests from testData/codegen/box directory. There are blackbox tests
in other directories and they are to be added.
2017-01-20 14:04:04 +03:00

17 lines
360 B
Kotlin

fun idiv(a: Int, b: Int): Int =
if (b == 0) throw Exception("Division by zero") else a / b
fun foo(): Int {
var sum = 0
for (i in -10 .. 10) {
sum += try { idiv(100, i) } catch (e: Exception) { continue }
}
return sum
}
fun box(): String {
val test = foo()
if (test != 0) return "Failed, test=$test"
return "OK"
}