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

Commit 8f2a9ae

Browse files
committed
Check exact values for specified cases
Inputs in `case_list` shouldn't hit xfails or increased ULP tolerance. Ensure that overrides are skipped when testing against MPFR or a specified value and that NaNs, if any, are checked bitwise.
1 parent c2bf953 commit 8f2a9ae

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,11 @@ fn rint_cases() -> Vec<TestCase<op::rint::Routine>> {
579579
TestCase::append_pairs(
580580
&mut v,
581581
&[
582-
// Failure on i586
582+
// Known failure on i586
583+
#[cfg(not(x86_no_sse))]
583584
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
585+
#[cfg(x86_no_sse)]
586+
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
584587
],
585588
);
586589
v
@@ -628,8 +631,11 @@ fn roundeven_cases() -> Vec<TestCase<op::roundeven::Routine>> {
628631
TestCase::append_pairs(
629632
&mut v,
630633
&[
631-
// Failure on i586
634+
// Known failure on i586
635+
#[cfg(not(x86_no_sse))]
632636
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
637+
#[cfg(x86_no_sse)]
638+
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
633639
],
634640
);
635641
v

crates/libm-test/src/test_traits.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use anyhow::{Context, anyhow, bail, ensure};
1212
use libm::support::Hexf;
1313

1414
use crate::precision::CheckAction;
15-
use crate::{CheckCtx, Float, Int, MaybeOverride, SpecialCase, TestResult};
15+
use crate::{
16+
CheckBasis, CheckCtx, Float, GeneratorKind, Int, MaybeOverride, SpecialCase, TestResult,
17+
};
1618

1719
/// Trait for calling a function with a tuple as arguments.
1820
///
@@ -207,6 +209,8 @@ where
207209
SpecialCase: MaybeOverride<Input>,
208210
{
209211
let (result, xfail_msg) = match SpecialCase::check_int(input, actual, expected, ctx) {
212+
// `require_biteq` forbids overrides.
213+
_ if ctx.gen_kind == GeneratorKind::List => (actual == expected, None),
210214
CheckAction::AssertSuccess => (actual == expected, None),
211215
CheckAction::AssertFailure(msg) => (actual != expected, Some(msg)),
212216
CheckAction::Custom(res) => return res,
@@ -291,7 +295,12 @@ where
291295
let mut inner = || -> TestResult {
292296
let mut allowed_ulp = ctx.ulp;
293297

298+
// Forbid overrides if the items came from an explicit list, as long as we are checking
299+
// against either MPFR or the result itself.
300+
let require_biteq = ctx.gen_kind == GeneratorKind::List && ctx.basis != CheckBasis::Musl;
301+
294302
match SpecialCase::check_float(input, actual, expected, ctx) {
303+
_ if require_biteq => (),
295304
CheckAction::AssertSuccess => (),
296305
CheckAction::AssertFailure(msg) => assert_failure_msg = Some(msg),
297306
CheckAction::Custom(res) => return res,
@@ -301,6 +310,9 @@ where
301310

302311
// Check when both are NaNs
303312
if actual.is_nan() && expected.is_nan() {
313+
if require_biteq && ctx.basis == CheckBasis::None {
314+
ensure!(actual.to_bits() == expected.to_bits(), "mismatched NaN bitpatterns");
315+
}
304316
// By default, NaNs have nothing special to check.
305317
return Ok(());
306318
} else if actual.is_nan() || expected.is_nan() {

0 commit comments

Comments
 (0)