Files
hakorune/tools/selfhost/test_pattern4_simple_continue.hako

42 lines
861 B
Plaintext
Raw Normal View History

// Phase 165: Test simple Pattern4 (continue) loop
// Simulates: loop(i < n) { if skip { continue } process i++ }
static box Main {
main(args) {
// Simple continue pattern: skip even numbers, sum odd numbers
local i = 0
local n = 10
local sum = 0
loop(i < n) {
// Skip even numbers
local is_even = 0
if i == 0 {
is_even = 1
} else if i == 2 {
is_even = 1
} else if i == 4 {
is_even = 1
} else if i == 6 {
is_even = 1
} else if i == 8 {
is_even = 1
}
if is_even == 1 {
i = i + 1
continue
}
// Sum odd numbers
sum = sum + i
i = i + 1
}
print("Pattern4 (Simple Continue) test")
print("Sum of odd numbers 0-10: " + ("" + sum))
print("Expected: 1 + 3 + 5 + 7 + 9 = 25")
return 0
}
}