| ... | ... | @@ -190,16 +190,16 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize { |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | | //test "inlined loop has array literal with elided runtime scope on first iteration but not second iteration" { |
| 194 | | // var runtime = [1]i32{3}; |
| 195 | | // comptime var i: usize = 0; |
| 196 | | // inline while (i < 2) : (i += 1) { |
| 197 | | // const result = if (i == 0) [1]i32{2} else runtime; |
| 198 | | // } |
| 199 | | // comptime { |
| 200 | | // expect(i == 2); |
| 201 | | // } |
| 202 | | //} |
| 193 | test "inlined loop has array literal with elided runtime scope on first iteration but not second iteration" { |
| 194 | var runtime = [1]i32{3}; |
| 195 | comptime var i: usize = 0; |
| 196 | inline while (i < 2) : (i += 1) { |
| 197 | const result = if (i == 0) [1]i32{2} else runtime; |
| 198 | } |
| 199 | comptime { |
| 200 | expect(i == 2); |
| 201 | } |
| 202 | } |
| 203 | 203 | |
| 204 | 204 | fn max(comptime T: type, a: T, b: T) T { |
| 205 | 205 | if (T == bool) { |
| ... | ... | @@ -668,9 +668,9 @@ fn loopNTimes(comptime n: usize) void { |
| 668 | 668 | inline while (i < n) : (i += 1) {} |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | | //test "variable inside inline loop that has different types on different iterations" { |
| 672 | | // testVarInsideInlineLoop(true, u32(42)); |
| 673 | | //} |
| 671 | test "variable inside inline loop that has different types on different iterations" { |
| 672 | testVarInsideInlineLoop(true, u32(42)); |
| 673 | } |
| 674 | 674 | |
| 675 | 675 | fn testVarInsideInlineLoop(args: ...) void { |
| 676 | 676 | comptime var i = 0; |
| ... | ... | @@ -681,14 +681,14 @@ fn testVarInsideInlineLoop(args: ...) void { |
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | | //test "inline for with same type but different values" { |
| 685 | | // var res: usize = 0; |
| 686 | | // inline for ([_]type{ [2]u8, [1]u8, [2]u8 }) |T| { |
| 687 | | // var a: T = undefined; |
| 688 | | // res += a.len; |
| 689 | | // } |
| 690 | | // expect(res == 5); |
| 691 | | //} |
| 684 | test "inline for with same type but different values" { |
| 685 | var res: usize = 0; |
| 686 | inline for ([_]type{ [2]u8, [1]u8, [2]u8 }) |T| { |
| 687 | var a: T = undefined; |
| 688 | res += a.len; |
| 689 | } |
| 690 | expect(res == 5); |
| 691 | } |
| 692 | 692 | |
| 693 | 693 | test "refer to the type of a generic function" { |
| 694 | 694 | const Func = fn (type) void; |