Skip to content

Doesn't work #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: float_tests_refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions library/coretests/tests/floats/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ fn test_num_f128() {
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
// the intrinsics.

#[test]
fn test_nan() {
let nan: f128 = f128::NAN;
assert!(nan.is_nan());
assert!(!nan.is_infinite());
assert!(!nan.is_finite());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert!(!nan.is_normal());
assert_eq!(Fp::Nan, nan.classify());
// Ensure the quiet bit is set.
assert!(nan.to_bits() & (1 << (f128::MANTISSA_DIGITS - 2)) != 0);
}

#[test]
fn test_infinity() {
let inf: f128 = f128::INFINITY;
Expand Down
14 changes: 0 additions & 14 deletions library/coretests/tests/floats/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ fn test_num_f16() {
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
// the intrinsics.

#[test]
fn test_nan() {
let nan: f16 = f16::NAN;
assert!(nan.is_nan());
assert!(!nan.is_infinite());
assert!(!nan.is_finite());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert!(!nan.is_normal());
assert_eq!(Fp::Nan, nan.classify());
// Ensure the quiet bit is set.
assert!(nan.to_bits() & (1 << (f16::MANTISSA_DIGITS - 2)) != 0);
}

#[test]
fn test_infinity() {
let inf: f16 = f16::INFINITY;
Expand Down
14 changes: 0 additions & 14 deletions library/coretests/tests/floats/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ fn test_num_f32() {
super::test_num(10f32, 2f32);
}

#[test]
fn test_nan() {
let nan: f32 = f32::NAN;
assert!(nan.is_nan());
assert!(!nan.is_infinite());
assert!(!nan.is_finite());
assert!(!nan.is_normal());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert_eq!(Fp::Nan, nan.classify());
// Ensure the quiet bit is set.
assert!(nan.to_bits() & (1 << (f32::MANTISSA_DIGITS - 2)) != 0);
}

#[test]
fn test_infinity() {
let inf: f32 = f32::INFINITY;
Expand Down
14 changes: 0 additions & 14 deletions library/coretests/tests/floats/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ fn test_num_f64() {
super::test_num(10f64, 2f64);
}

#[test]
fn test_nan() {
let nan: f64 = f64::NAN;
assert!(nan.is_nan());
assert!(!nan.is_infinite());
assert!(!nan.is_finite());
assert!(!nan.is_normal());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert_eq!(Fp::Nan, nan.classify());
// Ensure the quiet bit is set.
assert!(nan.to_bits() & (1 << (f64::MANTISSA_DIGITS - 2)) != 0);
}

#[test]
fn test_infinity() {
let inf: f64 = f64::INFINITY;
Expand Down
23 changes: 23 additions & 0 deletions library/coretests/tests/floats/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt;
use std::num::FpCategory as Fp;
use std::ops::{Add, Div, Mul, Rem, Sub};

/// Set the default tolerance for float comparison based on the type.
Expand Down Expand Up @@ -187,6 +188,7 @@ macro_rules! float_test {
mod const_ {
#[allow(unused)]
use super::Approx;
use super::*;
// Shadow the runtime versions of the macro with const-compatible versions.
#[allow(unused)]
use $crate::floats::{
Expand Down Expand Up @@ -250,6 +252,27 @@ mod f16;
mod f32;
mod f64;

float_test! {
name: nan,
attrs: {
const: #[cfg(false)],
f16: #[cfg(any(miri, target_has_reliable_f16))],
f128: #[cfg(any(miri, target_has_reliable_f128))],
},
test<Float> {
let nan: Float = Float::NAN;
assert!(nan.is_nan());
assert!(!nan.is_infinite());
assert!(!nan.is_finite());
assert!(!nan.is_normal());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert!(matches!(nan.classify(), Fp::Nan));
// Ensure the quiet bit is set.
assert!(nan.to_bits() & (1 << (Float::MANTISSA_DIGITS - 2)) != 0);
}
}

float_test! {
name: min,
attrs: {
Expand Down
Loading