zig/test/cases/void.zig
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00

31 lines
521 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];
}