|
3 | 3 |
|
4 | 4 | use testcrate::*;
|
5 | 5 |
|
6 |
| -mod int_addsub { |
7 |
| - use super::*; |
8 |
| - |
9 |
| - macro_rules! sum { |
10 |
| - ($($i:ty, $fn_add:ident, $fn_sub:ident);*;) => { |
11 |
| - $( |
12 |
| - #[test] |
13 |
| - fn $fn_add() { |
14 |
| - use compiler_builtins::int::addsub::{$fn_add, $fn_sub}; |
15 |
| - |
16 |
| - fuzz_2(N, |x: $i, y: $i| { |
17 |
| - let add0 = x.wrapping_add(y); |
18 |
| - let sub0 = x.wrapping_sub(y); |
19 |
| - let add1: $i = $fn_add(x, y); |
20 |
| - let sub1: $i = $fn_sub(x, y); |
21 |
| - if add0 != add1 { |
22 |
| - panic!( |
23 |
| - "{}({}, {}): std: {}, builtins: {}", |
24 |
| - stringify!($fn_add), x, y, add0, add1 |
25 |
| - ); |
26 |
| - } |
27 |
| - if sub0 != sub1 { |
28 |
| - panic!( |
29 |
| - "{}({}, {}): std: {}, builtins: {}", |
30 |
| - stringify!($fn_sub), x, y, sub0, sub1 |
31 |
| - ); |
32 |
| - } |
33 |
| - }); |
34 |
| - } |
35 |
| - )* |
36 |
| - }; |
37 |
| - } |
38 |
| - |
39 |
| - macro_rules! overflowing_sum { |
40 |
| - ($($i:ty, $fn_add:ident, $fn_sub:ident);*;) => { |
41 |
| - $( |
42 |
| - #[test] |
43 |
| - fn $fn_add() { |
44 |
| - use compiler_builtins::int::addsub::{$fn_add, $fn_sub}; |
45 |
| - |
46 |
| - fuzz_2(N, |x: $i, y: $i| { |
47 |
| - let add0 = x.overflowing_add(y); |
48 |
| - let sub0 = x.overflowing_sub(y); |
49 |
| - let add1: ($i, bool) = $fn_add(x, y); |
50 |
| - let sub1: ($i, bool) = $fn_sub(x, y); |
51 |
| - if add0.0 != add1.0 || add0.1 != add1.1 { |
52 |
| - panic!( |
53 |
| - "{}({}, {}): std: {:?}, builtins: {:?}", |
54 |
| - stringify!($fn_add), x, y, add0, add1 |
55 |
| - ); |
56 |
| - } |
57 |
| - if sub0.0 != sub1.0 || sub0.1 != sub1.1 { |
58 |
| - panic!( |
59 |
| - "{}({}, {}): std: {:?}, builtins: {:?}", |
60 |
| - stringify!($fn_sub), x, y, sub0, sub1 |
61 |
| - ); |
62 |
| - } |
63 |
| - }); |
64 |
| - } |
65 |
| - )* |
66 |
| - }; |
67 |
| - } |
68 |
| - |
69 |
| - // Integer addition and subtraction is very simple, so 100 fuzzing passes should be plenty. |
70 |
| - sum! { |
71 |
| - u128, __rust_u128_add, __rust_u128_sub; |
72 |
| - i128, __rust_i128_add, __rust_i128_sub; |
73 |
| - } |
74 |
| - |
75 |
| - overflowing_sum! { |
76 |
| - u128, __rust_u128_addo, __rust_u128_subo; |
77 |
| - i128, __rust_i128_addo, __rust_i128_subo; |
78 |
| - } |
79 |
| -} |
80 |
| - |
81 | 6 | macro_rules! float_sum {
|
82 | 7 | ($($f:ty, $fn_add:ident, $fn_sub:ident, $apfloat_ty:ident, $sys_available:meta);*;) => {
|
83 | 8 | $(
|
|
0 commit comments