aboutsummaryrefslogtreecommitdiff
path: root/test/cases/assert_function.7.zig
blob: 9db604d3b9c0026b7028d94dfd6e05f9c7802565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
extern "c" fn write(c_int, usize, usize) usize;

pub fn main() void {
    var i: u32 = 0;
    while (i < 4) : (i += 1) print();
    assert(i == 4);
}

fn print() void {
    _ = write(1, @intFromPtr("hello\n"), 6);
}

pub fn assert(ok: bool) void {
    if (!ok) unreachable; // assertion failure
}

// run
//
// hello
// hello
// hello
// hello
//