Files
kotlin/compiler/testData/codegen/box/finally/tryFinally.kt
Mikhael Bogdanov d0f042ba93 Properly generate exception table for try/catch block
KT-3549 'Finally' block not run when re-throwing exception
KT-3867 When catched exception occurs in finnaly block it invokes additional catch and itself

  #KT-3549 Fixed
  #KT-3867 Fixed
2013-08-19 16:06:56 +04:00

40 lines
865 B
Kotlin

fun unsupportedEx() = if (true) throw UnsupportedOperationException()
fun runtimeEx() = if (true) throw RuntimeException()
fun test1WithFinally() : String {
var s = "";
try {
try {
s += "Try";
unsupportedEx()
} finally {
s += "Finally"
}
} catch (x : RuntimeException) {
return s
}
return s + "Failed"
}
fun test2WithFinally() : String {
var s = "";
try {
try {
s += "Try";
unsupportedEx()
return s
} finally {
s += "Finally"
}
} catch (x : RuntimeException) {
return s
}
}
fun box() : String {
if (test1WithFinally() != "TryFinally") return "fail2: ${test1WithFinally()}"
if (test2WithFinally() != "TryFinally") return "fail4: ${test2WithFinally()}"
return "OK"
}