mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
e3424332d3
* `doc/langref` formatting * upgrade `.{ .path = "..." }` to `b.path("...")` * avoid using arguments named `self` * make `Build.Step.Id` usage more consistent * add `Build.pathResolve` * use `pathJoin` and `pathResolve` everywhere * make sure `Build.LazyPath.getPath2` returns an absolute path
23 lines
454 B
Zig
23 lines
454 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
test "inline for loop" {
|
|
const nums = [_]i32{ 2, 4, 6 };
|
|
var sum: usize = 0;
|
|
inline for (nums) |i| {
|
|
const T = switch (i) {
|
|
2 => f32,
|
|
4 => i8,
|
|
6 => bool,
|
|
else => unreachable,
|
|
};
|
|
sum += typeNameLength(T);
|
|
}
|
|
try expect(sum == 9);
|
|
}
|
|
|
|
fn typeNameLength(comptime T: type) usize {
|
|
return @typeName(T).len;
|
|
}
|
|
|
|
// test
|