saqut-compiler/tests/golden/loops/for_break_continue.sqt

25 lines
625 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// for döngüsünde break ve continue golden testi.
//
// continue kanıtı: 2 ve 4 atlanır ama güncelleme (i++) hala çalışır.
// Eğer continue güncellemeyi atlasaydı i==2'de sonsuz döngüye girerdi.
// 5'in çıktıda görünmesi güncellemenin çalıştığını kanıtlar.
//
// break kanıtı: i==3'te erken çık — 3, 4, 5 görünmemeli.
int main() {
int i = 0;
for (i = 1; i <= 5; i = i + 1) {
if (i == 2) { continue; }
if (i == 4) { continue; }
print(i);
}
for (i = 1; i <= 5; i = i + 1) {
if (i == 3) { break; }
print(i);
}
return 0;
}