Files
kotlin-fork/js/js.translator/testData/expression/if/cases/nestedIf.kt
T
Michael Nedzelsky 53f0e6dcd2 JS backend: remove dangerous package, correct translation for call, assignments, binary operations, support try...catch as expression
#KT-5576 Fixed
 #KT-5594 Fixed
 #KT-3166 Fixed
 #KT-5545 Fixed
 #KT-5594 Fixed
 #KT-5258 Fixed

JS backend: fix KT-4879: extra side effect when use when in default arguments

 #KT-4879 Fixed

JS backend: improve and fix WhenTranslator, fix order of evaluation for condtitions, fix KT-5263 (JS: extra tmp when initialize val in when by expression with if)

 #KT-5263 Fixed
2014-08-22 02:17:00 +04:00

36 lines
720 B
Kotlin

// JS: generate wrong code for nested if
// http://youtrack.jetbrains.com/issue/KT-5576
package foo
fun test2(a: Boolean, b: Boolean, c: Boolean) {
val a =
if (a) {
if (b) {
"1"
} else if (c) {
"2"
} else {
throw Exception("Rest parameter must be array types")
}
}
else {
"3"
}
}
fun box(): String {
test2(true, true, false)
var wasException = false
try {
test2(true, false, false)
}
catch(e: Exception) {
wasException = true
}
assertEquals(true, wasException)
return "OK"
}