master
1const expect = @import("std").testing.expect;
2
3test "inline while loop" {
4 comptime var i = 0;
5 var sum: usize = 0;
6 inline while (i < 3) : (i += 1) {
7 const T = switch (i) {
8 0 => f32,
9 1 => i8,
10 2 => bool,
11 else => unreachable,
12 };
13 sum += typeNameLength(T);
14 }
15 try expect(sum == 9);
16}
17
18fn typeNameLength(comptime T: type) usize {
19 return @typeName(T).len;
20}
21
22// test