| ... | ... | @@ -1073,21 +1073,11 @@ test "@mulWithOverflow bitsize > 32" { |
| 1073 | 1073 | try testMulWithOverflow(i63, minInt(i63), minInt(i63), 0, 1); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | | fn captureMultiply(comptime T: type) type { |
| 1077 | | return struct { |
| 1078 | | opA: T, |
| 1076 | fn testMutiplyUnwrap(comptime T: type, wrapped_a: anyerror!T, comptime b: T, expected: T) !void { |
| 1077 | const a = try wrapped_a; |
| 1079 | 1078 | |
| 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); |
| 1091 | 1081 | } |
| 1092 | 1082 | |
| 1093 | 1083 | test "Multiply unwrap error * immediate" { |
| ... | ... | @@ -1096,10 +1086,10 @@ test "Multiply unwrap error * immediate" { |
| 1096 | 1086 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 1097 | 1087 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; |
| 1098 | 1088 | |
| 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); |
| 1103 | 1093 | } |
| 1104 | 1094 | |
| 1105 | 1095 | test "@mulWithOverflow bitsize 128 bits" { |