authorgravatar for mathieusuen@yahoo.frMathieu Suen <mathieusuen@yahoo.fr> 2026-02-18 19:20:44+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-04-10 23:23:33+02:00
log244f5aafca25c2151fbdf80e54c1e8e08153a877
treedd70bd166ad8a86e561751038e517c843705ea6e
parent7addae8f7df4305d588c1583036d69a1ae08030c

fixup! Adding unwrapped error multiply regression test


1 files changed, 8 insertions(+), 18 deletions(-)

test/behavior/math.zig+8-18
......@@ -1073,21 +1073,11 @@ test "@mulWithOverflow bitsize > 32" {
10731073 try testMulWithOverflow(i63, minInt(i63), minInt(i63), 0, 1);
10741074}
10751075
1076fn captureMultiply(comptime T: type) type {
1077 return struct {
1078 opA: T,
1076fn testMutiplyUnwrap(comptime T: type, wrapped_a: anyerror!T, comptime b: T, expected: T) !void {
1077 const a = try wrapped_a;
10791078
1080 fn returnA(self: @This()) anyerror!T {
1081 return self.opA;
1082 }
1083
1084 fn testMutiplyWithOverflow(self: @This(), comptime b: T, expected: T) !void {
1085 const a = try self.returnA();
1086
1087 const c = a * b;
1088 try expectEqual(expected, c);
1089 }
1090 };
1079 const c = a * b;
1080 try expect(expected == c);
10911081}
10921082
10931083test "Multiply unwrap error * immediate" {
......@@ -1096,10 +1086,10 @@ test "Multiply unwrap error * immediate" {
10961086 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
10971087 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest;
10981088
1099 try (captureMultiply(i8){ .opA = 3 }).testMutiplyWithOverflow(-1, -3);
1100 try (captureMultiply(i16){ .opA = 3 }).testMutiplyWithOverflow(-1, -3);
1101 try (captureMultiply(i32){ .opA = 3 }).testMutiplyWithOverflow(-1, -3);
1102 try (captureMultiply(i64){ .opA = 3 }).testMutiplyWithOverflow(-1, -3);
1089 try testMutiplyUnwrap(i8, 3, -1, -3);
1090 try testMutiplyUnwrap(i16, 3, -1, -3);
1091 try testMutiplyUnwrap(i32, 3, -1, -3);
1092 try testMutiplyUnwrap(i64, 3, -1, -3);
11031093}
11041094
11051095test "@mulWithOverflow bitsize 128 bits" {