Expose algebraic floating point intrinsics by calder · Pull Request #136457 · rust-lang/rust (original) (raw)

Updated all tests to assert exact equality outside of MIRI.

To make this work I had to change assert_approx_eq() from diff < epsilon to diff <= epsilon:

--- a/library/std/tests/floats/lib.rs +++ b/library/std/tests/floats/lib.rs @@ -10,7 +10,7 @@ macro_rules! assert_approx_eq { let (a, b) = (&$a, &$b); let diff = (*a - *b).abs(); assert!(

266ca8b#diff-a4ab8b2578f382b20890fc918f6cdbffcaa057078f8793f0d974c011003a2b01R13

If we don't want to loosen that we'll need to do something like this instead:

--- a/library/std/tests/floats/f32.rs +++ b/library/std/tests/floats/f32.rs @@ -926,13 +926,17 @@ fn test_algebraic() { // This is a check of current implementations and does NOT imply any form of // guarantee about future behavior. The compiler reserves the right to make // these operations inexact matches in the future. - let eps_add = if cfg!(miri) { 1e-3 } else { 0.0 }; - let eps_mul = if cfg!(miri) { 1e-1 } else { 0.0 }; - let eps_div = if cfg!(miri) { 1e-4 } else { 0.0 };

}