diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-09-03 16:08:06 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-09-20 18:33:00 -0700 |
| commit | 426af68b7d234bceba029d65f3388ad2376da649 (patch) | |
| tree | f52425484ae66d4cbd636a60a86b1bf91478f0c2 /lib/std/testing.zig | |
| parent | 14bda4130a9a7f8b529b12bc74a1d6caa71b9545 (diff) | |
| download | zig-426af68b7d234bceba029d65f3388ad2376da649.tar.gz zig-426af68b7d234bceba029d65f3388ad2376da649.zip | |
compiler: require comptime vector indexes
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index b2dd271dc0..1cc1c4b4b5 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -135,9 +135,8 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { .array => |array| try expectEqualSlices(array.child, &expected, &actual), .vector => |info| { - var i: usize = 0; - while (i < info.len) : (i += 1) { - if (!std.meta.eql(expected[i], actual[i])) { + inline for (0..info.len) |i| { + if (expected[i] != actual[i]) { print("index {d} incorrect. expected {any}, found {any}\n", .{ i, expected[i], actual[i], }); @@ -828,8 +827,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).vector.len }); return error.TestExpectedEqual; } - var i: usize = 0; - while (i < info.len) : (i += 1) { + inline for (0..info.len) |i| { expectEqualDeep(expected[i], actual[i]) catch |e| { print("index {d} incorrect. expected {any}, found {any}\n", .{ i, expected[i], actual[i], |
