-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test against MPFR using random inputs
- Loading branch information
Showing
2 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Test with "infinite precision" | ||
|
||
use libm_test::gen::random; | ||
use libm_test::mpfloat::{self, MpOp}; | ||
use libm_test::multiprec_allowed_ulp; | ||
use libm_test::{CheckOutput, TupleCall}; | ||
|
||
/// Implement a test against MPFR with random inputs. | ||
macro_rules! multiprec_rand_tests { | ||
( | ||
fn_name: $fn_name:ident, | ||
CFn: $CFn:ty, | ||
CArgs: $CArgs:ty, | ||
CRet: $CRet:ty, | ||
RustFn: $RustFn:ty, | ||
RustArgs: $RustArgs:ty, | ||
RustRet: $RustRet:ty, | ||
attrs: [$($meta:meta)*] | ||
) => { | ||
paste::paste! { | ||
#[test] | ||
$(#[$meta])* | ||
fn [< multiprec_random_ $fn_name >]() { | ||
type MpOpTy = mpfloat::$fn_name::Operation; | ||
|
||
let fname = stringify!($fn_name); | ||
let ulp = multiprec_allowed_ulp(fname); | ||
let cases = random::get_test_cases::<$RustArgs>(fname); | ||
let mut mp_vals = MpOpTy::new(); | ||
|
||
for input in cases { | ||
let mp_res = mp_vals.run(input); | ||
let crate_res = input.call(libm::$fn_name as $RustFn); | ||
|
||
mp_res.validate(crate_res, input, ulp, fname).unwrap(); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
libm_macros::for_each_function! { | ||
callback: multiprec_rand_tests, | ||
attributes: [], | ||
skip: [ | ||
// FIXME: MPFR tests needed | ||
frexp, | ||
frexpf, | ||
ilogb, | ||
ilogbf, | ||
ldexp, | ||
ldexpf, | ||
modf, | ||
modff, | ||
remquo, | ||
remquof, | ||
scalbn, | ||
scalbnf, | ||
], | ||
attributes: [ | ||
// FIXME: we return NaN, musl returns -NaN | ||
#[cfg_attr(all(target_arch = "x86_64", target_os = "macos"), ignore)] | ||
[acosh, acoshf] | ||
], | ||
} |