|
2 | 2 | #![cfg(test)]
|
3 | 3 | #![cfg(feature = "system_libm")]
|
4 | 4 |
|
5 |
| -use libm_test::WithinUlps; |
| 5 | +use libm_test::{Call, WithinUlps}; |
6 | 6 |
|
7 | 7 | // Number of tests to generate for each function
|
8 | 8 | const NTESTS: usize = 500;
|
@@ -114,43 +114,6 @@ macro_rules! system_libm {
|
114 | 114 |
|
115 | 115 | libm_analyze::for_each_api!(system_libm);
|
116 | 116 |
|
117 |
| -// This implements function dispatch for tuples of arguments used in the tests |
118 |
| -// above, so that we can: (f32, 32).call(fn(f32, f32) -> f32) generically. |
119 |
| -// |
120 |
| -// We need the input parameter F to support dispatching, e.g., (f32,f32) with |
121 |
| -// functions that return both f32 or i32. Those are two different types, so we |
122 |
| -// need to be parametric over them. |
123 |
| -trait Call<F> { |
124 |
| - type Ret; |
125 |
| - fn call(self, f: F) -> Self::Ret; |
126 |
| -} |
127 |
| - |
128 |
| -macro_rules! impl_call { |
129 |
| - (($($arg_tys:ty),*) -> $ret_ty:ty: $self_:ident: $($xs:expr),*) => { |
130 |
| - // We only care about unsafe extern "C" functions here, safe functions coerce to them: |
131 |
| - impl Call<unsafe extern"C" fn($($arg_tys),*) -> $ret_ty> for ($($arg_tys,)+) { |
132 |
| - type Ret = $ret_ty; |
133 |
| - fn call(self, f: unsafe extern "C" fn($($arg_tys),*) -> $ret_ty) -> Self::Ret { |
134 |
| - let $self_ = self; |
135 |
| - unsafe { f($($xs),*) } |
136 |
| - } |
137 |
| - } |
138 |
| - }; |
139 |
| -} |
140 |
| - |
141 |
| -impl_call!((f32) -> f32: x: x.0); |
142 |
| -impl_call!((f64) -> f64: x: x.0); |
143 |
| -impl_call!((f64) -> i32: x: x.0); |
144 |
| -impl_call!((f32) -> i32: x: x.0); |
145 |
| -impl_call!((f32, f32) -> f32: x: x.0, x.1); |
146 |
| -impl_call!((f64, f64) -> f64: x: x.0, x.1); |
147 |
| -impl_call!((f64, i32) -> f64: x: x.0, x.1); |
148 |
| -impl_call!((f32, i32) -> f32: x: x.0, x.1); |
149 |
| -impl_call!((i32, f64) -> f64: x: x.0, x.1); |
150 |
| -impl_call!((i32, f32) -> f32: x: x.0, x.1); |
151 |
| -impl_call!((f32, f32, f32) -> f32: x: x.0, x.1, x.2); |
152 |
| -impl_call!((f64, f64, f64) -> f64: x: x.0, x.1, x.2); |
153 |
| - |
154 | 117 | // We need to be able to generate random numbers for the types involved.
|
155 | 118 | //
|
156 | 119 | // Rand does this well, but we want to also test some other specific values.
|
|
0 commit comments