zig/test/cases/void.zig
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00

31 lines
520 B
Zig

const assert = @import("std").debug.assert;
const Foo = struct {
a: void,
b: i32,
c: void,
};
test "compare void with void compile time known" {
comptime {
const foo = Foo{
.a = {},
.b = 1,
.c = {},
};
assert(foo.a == {});
}
}
test "iterate over a void slice" {
var j: usize = 0;
for (times(10)) |_, i| {
assert(i == j);
j += 1;
}
}
fn times(n: usize) []const void {
return ([*]void)(undefined)[0..n];
}