about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoger Curley <rocurley@gmail.com>2025-07-10 05:53:40 -0400
committerRoger Curley <rocurley@gmail.com>2025-07-11 10:31:25 -0400
commitcfb66e5e88a4f5333b328df0b6363ded674f92b4 (patch)
treecac9cd4ffe845f988735728cc981a92edf0e1aed
parent855e0fe46e68d94e9f6147531b75ac2d488c548e (diff)
downloadrust-cfb66e5e88a4f5333b328df0b6363ded674f92b4.tar.gz
rust-cfb66e5e88a4f5333b328df0b6363ded674f92b4.zip
Consolidate infinity tests
-rw-r--r--library/coretests/tests/floats/f128.rs12
-rw-r--r--library/coretests/tests/floats/f16.rs12
-rw-r--r--library/coretests/tests/floats/f32.rs12
-rw-r--r--library/coretests/tests/floats/f64.rs12
-rw-r--r--library/coretests/tests/floats/mod.rs18
5 files changed, 18 insertions, 48 deletions
diff --git a/library/coretests/tests/floats/f128.rs b/library/coretests/tests/floats/f128.rs
index 38df09a91c1..1b7ac82c1e9 100644
--- a/library/coretests/tests/floats/f128.rs
+++ b/library/coretests/tests/floats/f128.rs
@@ -56,18 +56,6 @@ fn test_num_f128() {
 // the intrinsics.
 
 #[test]
-fn test_infinity() {
-    let inf: f128 = f128::INFINITY;
-    assert!(inf.is_infinite());
-    assert!(!inf.is_finite());
-    assert!(inf.is_sign_positive());
-    assert!(!inf.is_sign_negative());
-    assert!(!inf.is_nan());
-    assert!(!inf.is_normal());
-    assert_eq!(Fp::Infinite, inf.classify());
-}
-
-#[test]
 fn test_neg_infinity() {
     let neg_inf: f128 = f128::NEG_INFINITY;
     assert!(neg_inf.is_infinite());
diff --git a/library/coretests/tests/floats/f16.rs b/library/coretests/tests/floats/f16.rs
index f6749d796cc..e69fe4d70bc 100644
--- a/library/coretests/tests/floats/f16.rs
+++ b/library/coretests/tests/floats/f16.rs
@@ -52,18 +52,6 @@ fn test_num_f16() {
 // the intrinsics.
 
 #[test]
-fn test_infinity() {
-    let inf: f16 = f16::INFINITY;
-    assert!(inf.is_infinite());
-    assert!(!inf.is_finite());
-    assert!(inf.is_sign_positive());
-    assert!(!inf.is_sign_negative());
-    assert!(!inf.is_nan());
-    assert!(!inf.is_normal());
-    assert_eq!(Fp::Infinite, inf.classify());
-}
-
-#[test]
 fn test_neg_infinity() {
     let neg_inf: f16 = f16::NEG_INFINITY;
     assert!(neg_inf.is_infinite());
diff --git a/library/coretests/tests/floats/f32.rs b/library/coretests/tests/floats/f32.rs
index f5d5723fea4..1efa8b3fdd5 100644
--- a/library/coretests/tests/floats/f32.rs
+++ b/library/coretests/tests/floats/f32.rs
@@ -36,18 +36,6 @@ fn test_num_f32() {
 }
 
 #[test]
-fn test_infinity() {
-    let inf: f32 = f32::INFINITY;
-    assert!(inf.is_infinite());
-    assert!(!inf.is_finite());
-    assert!(inf.is_sign_positive());
-    assert!(!inf.is_sign_negative());
-    assert!(!inf.is_nan());
-    assert!(!inf.is_normal());
-    assert_eq!(Fp::Infinite, inf.classify());
-}
-
-#[test]
 fn test_neg_infinity() {
     let neg_inf: f32 = f32::NEG_INFINITY;
     assert!(neg_inf.is_infinite());
diff --git a/library/coretests/tests/floats/f64.rs b/library/coretests/tests/floats/f64.rs
index 34af87c241e..9771abd2fe3 100644
--- a/library/coretests/tests/floats/f64.rs
+++ b/library/coretests/tests/floats/f64.rs
@@ -31,18 +31,6 @@ fn test_num_f64() {
 }
 
 #[test]
-fn test_infinity() {
-    let inf: f64 = f64::INFINITY;
-    assert!(inf.is_infinite());
-    assert!(!inf.is_finite());
-    assert!(inf.is_sign_positive());
-    assert!(!inf.is_sign_negative());
-    assert!(!inf.is_nan());
-    assert!(!inf.is_normal());
-    assert_eq!(Fp::Infinite, inf.classify());
-}
-
-#[test]
 fn test_neg_infinity() {
     let neg_inf: f64 = f64::NEG_INFINITY;
     assert!(neg_inf.is_infinite());
diff --git a/library/coretests/tests/floats/mod.rs b/library/coretests/tests/floats/mod.rs
index 36743a7d6df..9fe74090f15 100644
--- a/library/coretests/tests/floats/mod.rs
+++ b/library/coretests/tests/floats/mod.rs
@@ -274,6 +274,24 @@ float_test! {
 }
 
 float_test! {
+    name: infinity,
+    attrs: {
+        f16: #[cfg(any(miri, target_has_reliable_f16))],
+        f128: #[cfg(any(miri, target_has_reliable_f128))],
+    },
+    test<Float> {
+        let inf: Float = Float::INFINITY;
+        assert!(inf.is_infinite());
+        assert!(!inf.is_finite());
+        assert!(inf.is_sign_positive());
+        assert!(!inf.is_sign_negative());
+        assert!(!inf.is_nan());
+        assert!(!inf.is_normal());
+        assert!(matches!(inf.classify(), Fp::Infinite));
+    }
+}
+
+float_test! {
     name: min,
     attrs: {
         f16: #[cfg(any(miri, target_has_reliable_f16_math))],