Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 6838d3b

Browse files
committed
Check with sin
1 parent b3527c9 commit 6838d3b

File tree

3 files changed

+93
-7
lines changed

3 files changed

+93
-7
lines changed

crates/libm-test/src/gen/domain.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Does the following:
1616

1717
use std::ops::{Bound, RangeBounds};
1818

19-
use crate::Float;
2019
use crate::domain::{self, Domain};
20+
use crate::{CheckCtx, Float};
2121

2222
/// Number of values near an interesting point to check.
2323
const AROUND: usize = 100;
@@ -138,9 +138,14 @@ fn count_down<F: Float>(mut x: F) -> impl Iterator<Item = F> {
138138
})
139139
}
140140

141-
#[test]
142-
fn foobarbaz() {
143-
let values = near_bounds::<f32, domain::sin::D>();
141+
// #[test]
142+
// fn foobarbaz() {
143+
// let values = near_bounds::<f32, domain::sin::D>();
144144

145-
panic!("{}", values.len());
145+
// panic!("{}", values.len());
146+
// }
147+
148+
/// Create a test case iterator.
149+
pub fn get_test_cases<F: Float, D: Domain<F>>(ctx: &CheckCtx) -> impl Iterator<Item = (F,)> {
150+
near_bounds::<F, D>().into_iter().map(|v| (v,))
146151
}

crates/libm-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod domain;
1+
pub mod domain;
22
pub mod gen;
33
#[cfg(feature = "test-multiprecision")]
44
pub mod mpfloat;

crates/libm-test/tests/multiprecision.rs

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![cfg(feature = "test-multiprecision")]
44

5-
use libm_test::gen::random;
5+
use libm_test::gen::{domain, random};
66
use libm_test::mpfloat::{self, MpOp};
77
use libm_test::{CheckBasis, CheckCtx, CheckOutput, TupleCall, multiprec_allowed_ulp};
88

@@ -69,3 +69,84 @@ libm_macros::for_each_function! {
6969
nextafterf,
7070
],
7171
}
72+
73+
// macro_rules! multiprec_domain_tests {
74+
// (
75+
// fn_name: $fn_name:ident,
76+
// CFn: $CFn:ty,
77+
// CArgs: $CArgs:ty,
78+
// CRet: $CRet:ty,
79+
// RustFn: $RustFn:ty,
80+
// RustArgs: $RustArgs:ty,
81+
// RustRet: $RustRet:ty,
82+
// attrs: [$($meta:meta)*]
83+
// ) => {
84+
// paste::paste! {
85+
// #[test]
86+
// $(#[$meta])*
87+
// fn [< multiprec_domain_ $fn_name >]() {
88+
// type MpOpTy = mpfloat::$fn_name::Operation;
89+
90+
// let fname = stringify!($fn_name);
91+
// let ulp = multiprec_allowed_ulp(fname);
92+
// let mut mp_vals = MpOpTy::new();
93+
// let ctx = CheckCtx::new(ulp, fname, CheckBasis::Mpfr);
94+
// let cases = domain::get_test_cases::<$RustArgs>(&ctx);
95+
96+
// for input in cases {
97+
// let mp_res = mp_vals.run(input);
98+
// let crate_res = input.call(libm::$fn_name as $RustFn);
99+
100+
// crate_res.validate(mp_res, input, &ctx).unwrap();
101+
// }
102+
// }
103+
// }
104+
// };
105+
// }
106+
107+
// libm_macros::for_each_function! {
108+
// callback: multiprec_domain_tests,
109+
// attributes: [
110+
// // Also an assertion failure on i686: at `MPFR_ASSERTN (! mpfr_erangeflag_p ())`
111+
// #[ignore = "large values are infeasible in MPFR"]
112+
// [jn, jnf],
113+
// ],
114+
// skip: [
115+
// // FIXME: MPFR tests needed
116+
// frexp,
117+
// frexpf,
118+
// ilogb,
119+
// ilogbf,
120+
// ldexp,
121+
// ldexpf,
122+
// modf,
123+
// modff,
124+
// remquo,
125+
// remquof,
126+
// scalbn,
127+
// scalbnf,
128+
129+
// // FIXME: test needed, see
130+
// // https://github.com/rust-lang/libm/pull/311#discussion_r1818273392
131+
// nextafter,
132+
// nextafterf,
133+
// ],
134+
// }
135+
136+
#[test]
137+
fn multiprec_domain_sin() {
138+
type MpOpTy = mpfloat::sin::Operation;
139+
140+
let fname = "sin";
141+
let ulp = multiprec_allowed_ulp(fname);
142+
let mut mp_vals = MpOpTy::new();
143+
let ctx = CheckCtx::new(ulp, fname, CheckBasis::Mpfr);
144+
let cases = domain::get_test_cases::<f64, libm_test::domain::sin::D>(&ctx);
145+
146+
for input in cases {
147+
let mp_res = mp_vals.run(input);
148+
let crate_res = input.call(libm::sin as fn(f64) -> f64);
149+
150+
crate_res.validate(mp_res, input, &ctx).unwrap();
151+
}
152+
}

0 commit comments

Comments
 (0)