'containsBreak' checks that 'break' belongs to the right loop

This commit is contained in:
svtk
2011-10-13 17:15:10 +04:00
parent d9b4c972f7
commit e32409e4bf
2 changed files with 78 additions and 11 deletions
@@ -25,4 +25,61 @@ class C {
<!NOT_A_LOOP_LABEL!>break@f<!>
}
fun containsBreak(a: String?, b: String?) {
while (a == null) {
break;
}
a?.compareTo("2")
}
fun notContainsBreak(a: String?, b: String?) {
while (a == null) {
while (b == null) {
break;
}
}
a<!UNNECESSARY_SAFE_CALL!>?.<!>compareTo("2")
}
fun containsBreakWithLabel(a: String?) {
@loop while(a == null) {
break@loop
}
a?.compareTo("2")
}
fun containsIllegalBreak(a: String?) {
@loop while(a == null) {
<!NOT_A_LOOP_LABEL!>break<!UNRESOLVED_REFERENCE!>@label<!><!>
}
a<!UNNECESSARY_SAFE_CALL!>?.<!>compareTo("2")
}
fun containsBreakToOuterLoop(a: String?, b: String?) {
@loop while(b == null) {
while(a == null) {
break@loop
}
a<!UNNECESSARY_SAFE_CALL!>?.<!>compareTo("2")
}
}
fun containsBreakInsideLoopWithLabel(a: String?, array: Array<Int>) {
@ while(a == null) {
for (el in array) {
break@
}
}
a?.compareTo("2")
}
fun unresolvedBreak(a: String?, array: Array<Int>) {
while(a == null) {
@ for (el in array) {
break
}
if (true) break else <!NOT_A_LOOP_LABEL!>break<!UNRESOLVED_REFERENCE!>@<!><!>
}
a?.compareTo("2")
}
}