@@ -12,7 +12,9 @@ use anyhow::{Context, anyhow, bail, ensure};
1212use libm:: support:: Hexf ;
1313
1414use 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