diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-18 01:54:52 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-18 01:54:52 +0000 |
| commit | 1eed9181e082883987116224a5043b8b64a0ec95 (patch) | |
| tree | 75b57956dd7c565886c613ae49e1b181caa6b661 /tests | |
| parent | efb6cda22ec9ca124c22b40d1b0049c3992bbf32 (diff) | |
Support for '..='
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/control_flow/test_loops.zc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/control_flow/test_loops.zc b/tests/control_flow/test_loops.zc index 9968cf5..882ae7b 100644 --- a/tests/control_flow/test_loops.zc +++ b/tests/control_flow/test_loops.zc @@ -131,3 +131,36 @@ test "test_range_loops_generic" { "-> Range loops work with any integer type!"; } + +test "inclusive range basic" { + var count1 = 0 + for i in 0..=5 { + count1 += 1 + } + assert(count1 == 6, "Expected 6 iterations for 0..=5") +} + +test "inclusive range single" { + var count2 = 0 + for i in 0..=0 { + count2 += 1 + } + assert(count2 == 1, "Expected 1 iteration for 0..=0") +} + +test "inclusive range with step" { + var sum = 0 + for i in 0..=10 step 2 { + sum += i + } + // 0, 2, 4, 6, 8, 10 -> sum = 30 + assert(sum == 30, "Expected sum 30 for 0..=10 step 2") +} + +test "exclusive range regression check" { + var count3 = 0 + for i in 0..5 { + count3 += 1 + } + assert(count3 == 5, "Expected 5 iterations for 0..5") +} |
