Files
kotlin-fork/compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryCatchFinally.kt
T
2021-06-07 15:35:12 +03:00

28 lines
581 B
Kotlin
Vendored

@CompileTimeCalculation
fun tryCatch(integer: Int): String {
var str = ""
try {
str += "Start dividing\n"
val a = 10 / integer
str += "Without exception\n"
} catch (e: ArithmeticException) {
str += "Exception\n"
} finally {
str += "Finally\n"
}
return str
}
const val a1 = <!EVALUATED: `Start dividing
Exception
Finally
`!>tryCatch(0)<!>
const val a2 = <!EVALUATED: `Start dividing
Without exception
Finally
`!>tryCatch(1)<!>
const val a3 = <!EVALUATED: `Start dividing
Without exception
Finally
`!>tryCatch(100)<!>