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.
This commit is contained in:
Trevor Gross 2025-02-11 07:45:14 +00:00 committed by Trevor Gross
parent 53a055049c
commit 7db47c741c
2 changed files with 21 additions and 3 deletions

View file

@ -579,8 +579,11 @@ fn rint_cases() -> Vec<TestCase<op::rint::Routine>> {
TestCase::append_pairs(
&mut v,
&[
// Failure on i586
// Known failure on i586
#[cfg(not(x86_no_sse))]
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
#[cfg(x86_no_sse)]
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
],
);
v
@ -628,8 +631,11 @@ fn roundeven_cases() -> Vec<TestCase<op::roundeven::Routine>> {
TestCase::append_pairs(
&mut v,
&[
// Failure on i586
// Known failure on i586
#[cfg(not(x86_no_sse))]
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
#[cfg(x86_no_sse)]
((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
],
);
v

View file

@ -12,7 +12,9 @@ use anyhow::{Context, anyhow, bail, ensure};
use libm::support::Hexf;
use crate::precision::CheckAction;
use crate::{CheckCtx, Float, Int, MaybeOverride, SpecialCase, TestResult};
use crate::{
CheckBasis, CheckCtx, Float, GeneratorKind, Int, MaybeOverride, SpecialCase, TestResult,
};
/// Trait for calling a function with a tuple as arguments.
///
@ -207,6 +209,8 @@ where
SpecialCase: MaybeOverride<Input>,
{
let (result, xfail_msg) = match SpecialCase::check_int(input, actual, expected, ctx) {
// `require_biteq` forbids overrides.
_ if ctx.gen_kind == GeneratorKind::List => (actual == expected, None),
CheckAction::AssertSuccess => (actual == expected, None),
CheckAction::AssertFailure(msg) => (actual != expected, Some(msg)),
CheckAction::Custom(res) => return res,
@ -291,7 +295,12 @@ where
let mut inner = || -> TestResult {
let mut allowed_ulp = ctx.ulp;
// Forbid overrides if the items came from an explicit list, as long as we are checking
// against either MPFR or the result itself.
let require_biteq = ctx.gen_kind == GeneratorKind::List && ctx.basis != CheckBasis::Musl;
match SpecialCase::check_float(input, actual, expected, ctx) {
_ if require_biteq => (),
CheckAction::AssertSuccess => (),
CheckAction::AssertFailure(msg) => assert_failure_msg = Some(msg),
CheckAction::Custom(res) => return res,
@ -301,6 +310,9 @@ where
// Check when both are NaNs
if actual.is_nan() && expected.is_nan() {
if require_biteq && ctx.basis == CheckBasis::None {
ensure!(actual.to_bits() == expected.to_bits(), "mismatched NaN bitpatterns");
}
// By default, NaNs have nothing special to check.
return Ok(());
} else if actual.is_nan() || expected.is_nan() {