KT-2423 Jump after condition check in inner loop is to the wrong label

#KT-2423 Fixed
This commit is contained in:
Alexander Udalov
2012-07-23 20:09:58 +04:00
parent 69e1b8d407
commit 6eb4cf5aa5
3 changed files with 55 additions and 20 deletions
@@ -0,0 +1,46 @@
fun ok1(): Boolean {
val queue = linkedList(1, 2, 3)
while (!queue.isEmpty()) {
queue.poll()
for (y in 1..3) {
if (queue.contains(y)) {
return true
}
}
}
return false
}
fun ok2(): Boolean {
val queue = linkedList(1, 2, 3)
val array = array(1, 2, 3)
while (!queue.isEmpty()) {
queue.poll()
for (y in array) {
if (queue.contains(y)) {
return true
}
}
}
return false
}
fun ok3(): Boolean {
val queue = linkedList(1, 2, 3)
while (!queue.isEmpty()) {
queue.poll()
var x = 0
do {
x++
if (x == 2) return true
} while (x < 2)
}
return false
}
fun box(): String {
if (!ok1()) return "Fail #1"
if (!ok2()) return "Fail #2"
if (!ok3()) return "Fail #3"
return "OK"
}