mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
23 lines
454 B
Zig
23 lines
454 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
test "inline while loop" {
|
|
comptime var i = 0;
|
|
var sum: usize = 0;
|
|
inline while (i < 3) : (i += 1) {
|
|
const T = switch (i) {
|
|
0 => f32,
|
|
1 => i8,
|
|
2 => bool,
|
|
else => unreachable,
|
|
};
|
|
sum += typeNameLength(T);
|
|
}
|
|
try expect(sum == 9);
|
|
}
|
|
|
|
fn typeNameLength(comptime T: type) usize {
|
|
return @typeName(T).len;
|
|
}
|
|
|
|
// test
|