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

Commit 448d351

Browse files
committed
Check updates
1 parent fd82c65 commit 448d351

File tree

3 files changed

+49
-27
lines changed

3 files changed

+49
-27
lines changed

crates/libm-test/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ pub fn multiprec_allowed_ulp(name: &str) -> u32 {
5555
"asinh" | "asinhf" => 2,
5656
"atanh" | "atanhf" => 2,
5757
"exp10" | "exp10f" => 3,
58-
"j0" | "j0f" => 2,
59-
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 2,
58+
"j0" | "j0f" | "j1" | "j1f" => 16,
59+
"jn" | "jnf" => 2000,
60+
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 16,
6061
"sinh" | "sinhf" => 2,
62+
"sincosf" => 50,
6163
"tanh" | "tanhf" => 2,
6264
"tgamma" => 6,
6365
_ => MULTIPREC_DEFAULT_ULP,

crates/libm-test/src/special_case.rs

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ impl MaybeOverride<(f32,)> for SpecialCase {
5858
ctx: &CheckCtx,
5959
) -> Option<TestResult> {
6060
if ctx.basis == CheckBasis::Musl {
61-
if ctx.fname == "acoshf" && input.0 < -1.0 {
62-
// acoshf is undefined for x <= 1.0, but we return a random result at lower
63-
// values.
64-
return XFAIL;
65-
}
66-
6761
if ctx.fname == "sincosf" {
6862
let factor_frac_pi_2 = input.0.abs() / f32::consts::FRAC_PI_2;
6963
if (factor_frac_pi_2 - factor_frac_pi_2.round()).abs() < 1e-2 {
@@ -82,11 +76,17 @@ impl MaybeOverride<(f32,)> for SpecialCase {
8276
// doesn't seem to happen on x86
8377
return XFAIL;
8478
}
79+
}
8580

86-
if ctx.fname == "lgammaf" || ctx.fname == "lgammaf_r" && input.0 < 0.0 {
87-
// loggamma should not be defined for x < 0, yet we both return results
88-
return XFAIL;
89-
}
81+
if ctx.fname == "acoshf" && input.0 < -1.0 {
82+
// acoshf is undefined for x <= 1.0, but we return a random result at lower
83+
// values.
84+
return XFAIL;
85+
}
86+
87+
if ctx.fname == "lgammaf" || ctx.fname == "lgammaf_r" && input.0 < 0.0 {
88+
// loggamma should not be defined for x < 0, yet we both return results
89+
return XFAIL;
9090
}
9191

9292
maybe_check_nan_bits(actual, expected, ctx)
@@ -136,11 +136,17 @@ impl MaybeOverride<(f64,)> for SpecialCase {
136136
// musl returns -0.0, we return +0.0
137137
return XFAIL;
138138
}
139+
}
139140

140-
if ctx.fname == "lgamma" || ctx.fname == "lgamma_r" && input.0 < 0.0 {
141-
// loggamma should not be defined for x < 0, yet we both return results
142-
return XFAIL;
143-
}
141+
if ctx.fname == "acosh" && input.0 < 1.0 {
142+
// The function is undefined for the inputs, musl and our libm both return
143+
// random results.
144+
return XFAIL;
145+
}
146+
147+
if ctx.fname == "lgamma" || ctx.fname == "lgamma_r" && input.0 < 0.0 {
148+
// loggamma should not be defined for x < 0, yet we both return results
149+
return XFAIL;
144150
}
145151

146152
maybe_check_nan_bits(actual, expected, ctx)
@@ -188,7 +194,7 @@ impl MaybeOverride<(f32, f32)> for SpecialCase {
188194
_ulp: &mut u32,
189195
ctx: &CheckCtx,
190196
) -> Option<TestResult> {
191-
maybe_skip_min_max_nan(input, expected, ctx)
197+
maybe_skip_binop_nan(input, expected, ctx)
192198
}
193199
}
194200
impl MaybeOverride<(f64, f64)> for SpecialCase {
@@ -199,24 +205,35 @@ impl MaybeOverride<(f64, f64)> for SpecialCase {
199205
_ulp: &mut u32,
200206
ctx: &CheckCtx,
201207
) -> Option<TestResult> {
202-
maybe_skip_min_max_nan(input, expected, ctx)
208+
maybe_skip_binop_nan(input, expected, ctx)
203209
}
204210
}
205211

206212
/// Musl propagates NaNs if one is provided as the input, but we return the other input.
207213
// F1 and F2 are always the same type, this is just to please generics
208-
fn maybe_skip_min_max_nan<F1: Float, F2: Float>(
214+
fn maybe_skip_binop_nan<F1: Float, F2: Float>(
209215
input: (F1, F1),
210216
expected: F2,
211217
ctx: &CheckCtx,
212218
) -> Option<TestResult> {
213-
if (ctx.canonical_name == "fmax" || ctx.canonical_name == "fmin")
214-
&& (input.0.is_nan() || input.1.is_nan())
215-
&& expected.is_nan()
216-
{
217-
return XFAIL;
218-
} else {
219-
None
219+
match ctx.basis {
220+
CheckBasis::Musl => {
221+
if (ctx.canonical_name == "fmax" || ctx.canonical_name == "fmin")
222+
&& (input.0.is_nan() || input.1.is_nan())
223+
&& expected.is_nan()
224+
{
225+
XFAIL
226+
} else {
227+
None
228+
}
229+
}
230+
CheckBasis::MultiPrecision => {
231+
if ctx.canonical_name == "copysign" && input.1.is_nan() {
232+
SKIP
233+
} else {
234+
None
235+
}
236+
}
220237
}
221238
}
222239

crates/libm-test/tests/multiprecision.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ macro_rules! multiprec_rand_tests {
3434
let mp_res = mp_vals.run(input);
3535
let crate_res = input.call(libm::$fn_name as $RustFn);
3636

37-
mp_res.validate(crate_res, input, &ctx).unwrap();
37+
crate_res.validate(mp_res, input, &ctx).unwrap();
3838
}
3939
}
4040
}
@@ -58,5 +58,8 @@ libm_macros::for_each_function! {
5858
remquof,
5959
scalbn,
6060
scalbnf,
61+
62+
jn,
63+
jnf,
6164
],
6265
}

0 commit comments

Comments
 (0)