Rollup merge of #129835 - RalfJung:float-tests, r=workingjubilee
enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to https://github.com/rust-lang/rust/issues/114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by https://github.com/rust-lang/rust/pull/123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in #123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc ```@tgross35``` ```@workingjubilee```
This commit is contained in:
commit
312b597a7e
11 changed files with 254 additions and 282 deletions
|
@ -2,31 +2,24 @@ use crate::f32::consts;
|
|||
use crate::num::{FpCategory as Fp, *};
|
||||
|
||||
/// Smallest number
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const TINY_BITS: u32 = 0x1;
|
||||
|
||||
/// Next smallest number
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const TINY_UP_BITS: u32 = 0x2;
|
||||
|
||||
/// Exponent = 0b11...10, Sifnificand 0b1111..10. Min val > 0
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const MAX_DOWN_BITS: u32 = 0x7f7f_fffe;
|
||||
|
||||
/// Zeroed exponent, full significant
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const LARGEST_SUBNORMAL_BITS: u32 = 0x007f_ffff;
|
||||
|
||||
/// Exponent = 0b1, zeroed significand
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const SMALLEST_NORMAL_BITS: u32 = 0x0080_0000;
|
||||
|
||||
/// First pattern over the mantissa
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const NAN_MASK1: u32 = 0x002a_aaaa;
|
||||
|
||||
/// Second pattern over the mantissa
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const NAN_MASK2: u32 = 0x0055_5555;
|
||||
|
||||
#[allow(unused_macros)]
|
||||
|
@ -353,9 +346,6 @@ fn test_is_sign_negative() {
|
|||
assert!((-f32::NAN).is_sign_negative());
|
||||
}
|
||||
|
||||
// Ignore test on x87 floating point, these platforms do not guarantee NaN
|
||||
// payloads are preserved and flush denormals to zero, failing the tests.
|
||||
#[cfg(not(target_arch = "x86"))]
|
||||
#[test]
|
||||
fn test_next_up() {
|
||||
let tiny = f32::from_bits(TINY_BITS);
|
||||
|
@ -386,9 +376,6 @@ fn test_next_up() {
|
|||
assert_f32_biteq!(nan2.next_up(), nan2);
|
||||
}
|
||||
|
||||
// Ignore test on x87 floating point, these platforms do not guarantee NaN
|
||||
// payloads are preserved and flush denormals to zero, failing the tests.
|
||||
#[cfg(not(target_arch = "x86"))]
|
||||
#[test]
|
||||
fn test_next_down() {
|
||||
let tiny = f32::from_bits(TINY_BITS);
|
||||
|
|
|
@ -2,31 +2,24 @@ use crate::f64::consts;
|
|||
use crate::num::{FpCategory as Fp, *};
|
||||
|
||||
/// Smallest number
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const TINY_BITS: u64 = 0x1;
|
||||
|
||||
/// Next smallest number
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const TINY_UP_BITS: u64 = 0x2;
|
||||
|
||||
/// Exponent = 0b11...10, Sifnificand 0b1111..10. Min val > 0
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const MAX_DOWN_BITS: u64 = 0x7fef_ffff_ffff_fffe;
|
||||
|
||||
/// Zeroed exponent, full significant
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const LARGEST_SUBNORMAL_BITS: u64 = 0x000f_ffff_ffff_ffff;
|
||||
|
||||
/// Exponent = 0b1, zeroed significand
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const SMALLEST_NORMAL_BITS: u64 = 0x0010_0000_0000_0000;
|
||||
|
||||
/// First pattern over the mantissa
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const NAN_MASK1: u64 = 0x000a_aaaa_aaaa_aaaa;
|
||||
|
||||
/// Second pattern over the mantissa
|
||||
#[allow(dead_code)] // unused on x86
|
||||
const NAN_MASK2: u64 = 0x0005_5555_5555_5555;
|
||||
|
||||
#[allow(unused_macros)]
|
||||
|
@ -343,9 +336,6 @@ fn test_is_sign_negative() {
|
|||
assert!((-f64::NAN).is_sign_negative());
|
||||
}
|
||||
|
||||
// Ignore test on x87 floating point, these platforms do not guarantee NaN
|
||||
// payloads are preserved and flush denormals to zero, failing the tests.
|
||||
#[cfg(not(target_arch = "x86"))]
|
||||
#[test]
|
||||
fn test_next_up() {
|
||||
let tiny = f64::from_bits(TINY_BITS);
|
||||
|
@ -375,9 +365,6 @@ fn test_next_up() {
|
|||
assert_f64_biteq!(nan2.next_up(), nan2);
|
||||
}
|
||||
|
||||
// Ignore test on x87 floating point, these platforms do not guarantee NaN
|
||||
// payloads are preserved and flush denormals to zero, failing the tests.
|
||||
#[cfg(not(target_arch = "x86"))]
|
||||
#[test]
|
||||
fn test_next_down() {
|
||||
let tiny = f64::from_bits(TINY_BITS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue