authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2023-10-07 22:42:12+02:00
committergravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-01-03 21:20:48+01:00
log4c1da0912a474228750362a11db85799cac311b9
tree36dad7e9e43856d0ec0b12d736c5133611d38e61
parente5994f5f573a51de4e604824355cac28b5ab4eba

Fix compile errors from the `expectEqual` change


7 files changed, 40 insertions(+), 38 deletions(-)

lib/std/math/float.zig+15-15
...@@ -138,11 +138,11 @@ test "math.inf" {...@@ -138,11 +138,11 @@ test "math.inf" {
138 const inf_u64: u64 = 0x7FF0000000000000;138 const inf_u64: u64 = 0x7FF0000000000000;
139 const inf_u80: u80 = 0x7FFF8000000000000000;139 const inf_u80: u80 = 0x7FFF8000000000000000;
140 const inf_u128: u128 = 0x7FFF0000000000000000000000000000;140 const inf_u128: u128 = 0x7FFF0000000000000000000000000000;
141 try expectEqual(inf_u16, @bitCast(inf(f16)));141 try expectEqual(inf_u16, @as(u16, @bitCast(inf(f16))));
142 try expectEqual(inf_u32, @bitCast(inf(f32)));142 try expectEqual(inf_u32, @as(u32, @bitCast(inf(f32))));
143 try expectEqual(inf_u64, @bitCast(inf(f64)));143 try expectEqual(inf_u64, @as(u64, @bitCast(inf(f64))));
144 try expectEqual(inf_u80, @bitCast(inf(f80)));144 try expectEqual(inf_u80, @as(u80, @bitCast(inf(f80))));
145 try expectEqual(inf_u128, @bitCast(inf(f128)));145 try expectEqual(inf_u128, @as(u128, @bitCast(inf(f128))));
146}146}
147147
148test "math.nan" {148test "math.nan" {
...@@ -151,11 +151,11 @@ test "math.nan" {...@@ -151,11 +151,11 @@ test "math.nan" {
151 const qnan_u64: u64 = 0x7FF8000000000000;151 const qnan_u64: u64 = 0x7FF8000000000000;
152 const qnan_u80: u80 = 0x7FFFC000000000000000;152 const qnan_u80: u80 = 0x7FFFC000000000000000;
153 const qnan_u128: u128 = 0x7FFF8000000000000000000000000000;153 const qnan_u128: u128 = 0x7FFF8000000000000000000000000000;
154 try expectEqual(qnan_u16, @bitCast(nan(f16)));154 try expectEqual(qnan_u16, @as(u16, @bitCast(nan(f16))));
155 try expectEqual(qnan_u32, @bitCast(nan(f32)));155 try expectEqual(qnan_u32, @as(u32, @bitCast(nan(f32))));
156 try expectEqual(qnan_u64, @bitCast(nan(f64)));156 try expectEqual(qnan_u64, @as(u64, @bitCast(nan(f64))));
157 try expectEqual(qnan_u80, @bitCast(nan(f80)));157 try expectEqual(qnan_u80, @as(u80, @bitCast(nan(f80))));
158 try expectEqual(qnan_u128, @bitCast(nan(f128)));158 try expectEqual(qnan_u128, @as(u128, @bitCast(nan(f128))));
159}159}
160160
161test "math.snan" {161test "math.snan" {
...@@ -167,9 +167,9 @@ test "math.snan" {...@@ -167,9 +167,9 @@ test "math.snan" {
167 const snan_u64: u64 = 0x7FF4000000000000;167 const snan_u64: u64 = 0x7FF4000000000000;
168 const snan_u80: u80 = 0x7FFFA000000000000000;168 const snan_u80: u80 = 0x7FFFA000000000000000;
169 const snan_u128: u128 = 0x7FFF4000000000000000000000000000;169 const snan_u128: u128 = 0x7FFF4000000000000000000000000000;
170 try expectEqual(snan_u16, @bitCast(snan(f16)));170 try expectEqual(snan_u16, @as(u16, @bitCast(snan(f16))));
171 try expectEqual(snan_u32, @bitCast(snan(f32)));171 try expectEqual(snan_u32, @as(u32, @bitCast(snan(f32))));
172 try expectEqual(snan_u64, @bitCast(snan(f64)));172 try expectEqual(snan_u64, @as(u64, @bitCast(snan(f64))));
173 try expectEqual(snan_u80, @bitCast(snan(f80)));173 try expectEqual(snan_u80, @as(u80, @bitCast(snan(f80))));
174 try expectEqual(snan_u128, @bitCast(snan(f128)));174 try expectEqual(snan_u128, @as(u128, @bitCast(snan(f128))));
175}175}
lib/std/mem.zig+6-4
...@@ -3262,7 +3262,7 @@ test "indexOfMax" {...@@ -3262,7 +3262,7 @@ test "indexOfMax" {
3262/// Finds the indices of the smallest and largest number in a slice. O(n).3262/// Finds the indices of the smallest and largest number in a slice. O(n).
3263/// Returns an anonymous struct with the fields `index_min` and `index_max`.3263/// Returns an anonymous struct with the fields `index_min` and `index_max`.
3264/// `slice` must not be empty.3264/// `slice` must not be empty.
3265pub fn indexOfMinMax(comptime T: type, slice: []const T) struct { index_min: usize, index_max: usize } {3265pub fn indexOfMinMax(comptime T: type, slice: []const T) IndexOfMinMaxResult {
3266 assert(slice.len > 0);3266 assert(slice.len > 0);
3267 var minVal = slice[0];3267 var minVal = slice[0];
3268 var maxVal = slice[0];3268 var maxVal = slice[0];
...@@ -3281,10 +3281,12 @@ pub fn indexOfMinMax(comptime T: type, slice: []const T) struct { index_min: usi...@@ -3281,10 +3281,12 @@ pub fn indexOfMinMax(comptime T: type, slice: []const T) struct { index_min: usi
3281 return .{ .index_min = minIdx, .index_max = maxIdx };3281 return .{ .index_min = minIdx, .index_max = maxIdx };
3282}3282}
32833283
3284pub const IndexOfMinMaxResult = struct { index_min: usize, index_max: usize };
3285
3284test "indexOfMinMax" {3286test "indexOfMinMax" {
3285 try testing.expectEqual(indexOfMinMax(u8, "abcdefg"), .{ .index_min = 0, .index_max = 6 });3287 try testing.expectEqual(indexOfMinMax(u8, "abcdefg"), IndexOfMinMaxResult{ .index_min = 0, .index_max = 6 });
3286 try testing.expectEqual(indexOfMinMax(u8, "gabcdef"), .{ .index_min = 1, .index_max = 0 });3288 try testing.expectEqual(indexOfMinMax(u8, "gabcdef"), IndexOfMinMaxResult{ .index_min = 1, .index_max = 0 });
3287 try testing.expectEqual(indexOfMinMax(u8, "a"), .{ .index_min = 0, .index_max = 0 });3289 try testing.expectEqual(indexOfMinMax(u8, "a"), IndexOfMinMaxResult{ .index_min = 0, .index_max = 0 });
3288}3290}
32893291
3290pub fn swap(comptime T: type, a: *T, b: *T) void {3292pub fn swap(comptime T: type, a: *T, b: *T) void {
lib/std/multi_array_list.zig+12-12
...@@ -842,24 +842,24 @@ test "union" {...@@ -842,24 +842,24 @@ test "union" {
842 &.{ .a, .b, .b, .a, .a, .a, .a, .a, .a },842 &.{ .a, .b, .b, .a, .a, .a, .a, .a, .a },
843 list.items(.tags),843 list.items(.tags),
844 );844 );
845 try testing.expectEqual(list.get(0), .{ .a = 1 });845 try testing.expectEqual(list.get(0), Foo{ .a = 1 });
846 try testing.expectEqual(list.get(1), .{ .b = "zigzag" });846 try testing.expectEqual(list.get(1), Foo{ .b = "zigzag" });
847 try testing.expectEqual(list.get(2), .{ .b = "foobar" });847 try testing.expectEqual(list.get(2), Foo{ .b = "foobar" });
848 try testing.expectEqual(list.get(3), .{ .a = 4 });848 try testing.expectEqual(list.get(3), Foo{ .a = 4 });
849 try testing.expectEqual(list.get(4), .{ .a = 5 });849 try testing.expectEqual(list.get(4), Foo{ .a = 5 });
850 try testing.expectEqual(list.get(5), .{ .a = 6 });850 try testing.expectEqual(list.get(5), Foo{ .a = 6 });
851 try testing.expectEqual(list.get(6), .{ .a = 7 });851 try testing.expectEqual(list.get(6), Foo{ .a = 7 });
852 try testing.expectEqual(list.get(7), .{ .a = 8 });852 try testing.expectEqual(list.get(7), Foo{ .a = 8 });
853 try testing.expectEqual(list.get(8), .{ .a = 9 });853 try testing.expectEqual(list.get(8), Foo{ .a = 9 });
854854
855 list.shrinkAndFree(ally, 3);855 list.shrinkAndFree(ally, 3);
856856
857 try testing.expectEqual(@as(usize, 3), list.items(.tags).len);857 try testing.expectEqual(@as(usize, 3), list.items(.tags).len);
858 try testing.expectEqualSlices(meta.Tag(Foo), list.items(.tags), &.{ .a, .b, .b });858 try testing.expectEqualSlices(meta.Tag(Foo), list.items(.tags), &.{ .a, .b, .b });
859859
860 try testing.expectEqual(list.get(0), .{ .a = 1 });860 try testing.expectEqual(list.get(0), Foo{ .a = 1 });
861 try testing.expectEqual(list.get(1), .{ .b = "zigzag" });861 try testing.expectEqual(list.get(1), Foo{ .b = "zigzag" });
862 try testing.expectEqual(list.get(2), .{ .b = "foobar" });862 try testing.expectEqual(list.get(2), Foo{ .b = "foobar" });
863}863}
864864
865test "sorting a span" {865test "sorting a span" {
test/behavior/cast.zig+1-1
...@@ -1156,7 +1156,7 @@ test "cast function with an opaque parameter" {...@@ -1156,7 +1156,7 @@ test "cast function with an opaque parameter" {
1156 .func = @ptrCast(&Foo.funcImpl),1156 .func = @ptrCast(&Foo.funcImpl),
1157 };1157 };
1158 c.func(c.ctx);1158 c.func(c.ctx);
1159 try std.testing.expectEqual(foo, .{ .x = 101, .y = 201 });1159 try std.testing.expectEqual(foo, Foo{ .x = 101, .y = 201 });
1160}1160}
11611161
1162test "implicit ptr to *anyopaque" {1162test "implicit ptr to *anyopaque" {
test/behavior/packed-struct.zig+1-1
...@@ -1033,7 +1033,7 @@ test "modify nested packed struct aligned field" {...@@ -1033,7 +1033,7 @@ test "modify nested packed struct aligned field" {
10331033
1034 var opts = Options{};1034 var opts = Options{};
1035 opts.pretty_print.indent += 1;1035 opts.pretty_print.indent += 1;
1036 try std.testing.expectEqual(@as(u17, 0b00000000100100000), @bitCast(opts));1036 try std.testing.expectEqual(@as(u17, 0b00000000100100000), @as(u17, @bitCast(opts)));
1037 try std.testing.expect(!opts.foo);1037 try std.testing.expect(!opts.foo);
1038 try std.testing.expect(!opts.bar);1038 try std.testing.expect(!opts.bar);
1039 try std.testing.expect(!opts.pretty_print.enabled);1039 try std.testing.expect(!opts.pretty_print.enabled);
test/behavior/type.zig+2-2
...@@ -438,9 +438,9 @@ test "Type.Union" {...@@ -438,9 +438,9 @@ test "Type.Union" {
438 },438 },
439 });439 });
440 var tagged = Tagged{ .signed = -1 };440 var tagged = Tagged{ .signed = -1 };
441 try testing.expectEqual(Tag.signed, tagged);441 try testing.expectEqual(Tag.signed, @as(Tag, tagged));
442 tagged = .{ .unsigned = 1 };442 tagged = .{ .unsigned = 1 };
443 try testing.expectEqual(Tag.unsigned, tagged);443 try testing.expectEqual(Tag.unsigned, @as(Tag, tagged));
444}444}
445445
446test "Type.Union from Type.Enum" {446test "Type.Union from Type.Enum" {
test/c_abi/main.zig+3-3
...@@ -946,7 +946,7 @@ test "DC: C returns to Zig" {...@@ -946,7 +946,7 @@ test "DC: C returns to Zig" {
946 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;946 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
947 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;947 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
948 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;948 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
949 try expectEqual(c_ret_DC(), .{ .v1 = -0.25, .v2 = 15 });949 try expectEqual(c_ret_DC(), DC{ .v1 = -0.25, .v2 = 15 });
950}950}
951951
952pub extern fn c_assert_DC(lv: DC) c_int;952pub extern fn c_assert_DC(lv: DC) c_int;
...@@ -998,7 +998,7 @@ test "CFF: C returns to Zig" {...@@ -998,7 +998,7 @@ test "CFF: C returns to Zig" {
998 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;998 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
999 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;999 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
1000 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;1000 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
1001 try expectEqual(c_ret_CFF(), .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 });1001 try expectEqual(c_ret_CFF(), CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 });
1002}1002}
1003pub extern fn c_assert_CFF(lv: CFF) c_int;1003pub extern fn c_assert_CFF(lv: CFF) c_int;
1004pub extern fn c_assert_ret_CFF() c_int;1004pub extern fn c_assert_ret_CFF() c_int;
...@@ -1045,7 +1045,7 @@ test "PD: C returns to Zig" {...@@ -1045,7 +1045,7 @@ test "PD: C returns to Zig" {
1045 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;1045 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
1046 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1046 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
1047 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;1047 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
1048 try expectEqual(c_ret_PD(), .{ .v1 = null, .v2 = 0.5 });1048 try expectEqual(c_ret_PD(), PD{ .v1 = null, .v2 = 0.5 });
1049}1049}
1050pub extern fn c_assert_PD(lv: PD) c_int;1050pub extern fn c_assert_PD(lv: PD) c_int;
1051pub extern fn c_assert_ret_PD() c_int;1051pub extern fn c_assert_ret_PD() c_int;