From 244f5aafca25c2151fbdf80e54c1e8e08153a877 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Wed, 18 Feb 2026 19:20:44 +0100 Subject: [PATCH] fixup! Adding unwrapped error multiply regression test --- test/behavior/math.zig | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 70a38386f45b5dc69b911d997598160c5a755533..254c8886334765e4b628aae896ac97d364c7983c 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -1073,21 +1073,11 @@ test "@mulWithOverflow bitsize > 32" { try testMulWithOverflow(i63, minInt(i63), minInt(i63), 0, 1); } -fn captureMultiply(comptime T: type) type { - return struct { - opA: T, +fn testMutiplyUnwrap(comptime T: type, wrapped_a: anyerror!T, comptime b: T, expected: T) !void { + const a = try wrapped_a; - fn returnA(self: @This()) anyerror!T { - return self.opA; - } - - fn testMutiplyWithOverflow(self: @This(), comptime b: T, expected: T) !void { - const a = try self.returnA(); - - const c = a * b; - try expectEqual(expected, c); - } - }; + const c = a * b; + try expect(expected == c); } test "Multiply unwrap error * immediate" { @@ -1096,10 +1086,10 @@ test "Multiply unwrap error * immediate" { if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; - try (captureMultiply(i8){ .opA = 3 }).testMutiplyWithOverflow(-1, -3); - try (captureMultiply(i16){ .opA = 3 }).testMutiplyWithOverflow(-1, -3); - try (captureMultiply(i32){ .opA = 3 }).testMutiplyWithOverflow(-1, -3); - try (captureMultiply(i64){ .opA = 3 }).testMutiplyWithOverflow(-1, -3); + try testMutiplyUnwrap(i8, 3, -1, -3); + try testMutiplyUnwrap(i16, 3, -1, -3); + try testMutiplyUnwrap(i32, 3, -1, -3); + try testMutiplyUnwrap(i64, 3, -1, -3); } test "@mulWithOverflow bitsize 128 bits" { -- 2.54.0