zig/test/cases/while_loops.zig
Alex Rønne Petersen 4dba253cd2
test: pull tests in test/cases/llvm/ up to test/cases/
There is nothing inherently LLVM-specific about any of these.
2025-09-16 23:39:29 +02:00

19 lines
293 B
Zig

fn assert(ok: bool) void {
if (!ok) unreachable;
}
pub fn main() void {
var sum: u32 = 0;
var i: u32 = 0;
while (i < 5) : (i += 1) {
sum += i;
}
assert(sum == 10);
assert(i == 5);
}
// run
// backend=selfhosted,llvm
// target=x86_64-linux,x86_64-macos
//