diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-09-21 01:49:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-21 01:49:28 -0700 |
| commit | 010d9a63f20d8a4bd14cff0ada690b2d127a0371 (patch) | |
| tree | 12b56ddfe5a5b235ef0676832902a0b04ad7d57a /lib/std/testing.zig | |
| parent | 3fbb88c4bd146ca7bd9e7ab5da9c4b05298f3b34 (diff) | |
| parent | 633162eb0c8d302ba7585cd308e01237409f042e (diff) | |
| download | zig-010d9a63f20d8a4bd14cff0ada690b2d127a0371.tar.gz zig-010d9a63f20d8a4bd14cff0ada690b2d127a0371.zip | |
Merge pull request #25154 from ziglang/no-decl-val-3
rework byval ZIR instructions; forbid runtime vector indexes
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index b2dd271dc0..1c6c639796 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -135,15 +135,9 @@ 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])) { - print("index {d} incorrect. expected {any}, found {any}\n", .{ - i, expected[i], actual[i], - }); - return error.TestExpectedEqual; - } - } + const expect_array: [info.len]info.child = expected; + const actual_array: [info.len]info.child = actual; + try expectEqualSlices(info.child, &expect_array, &actual_array); }, .@"struct" => |structType| { @@ -828,8 +822,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], |
