about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-05-12 10:21:00 +0200
committerRalf Jung <post@ralfj.de>2024-05-12 10:21:00 +0200
commit5d76ec9cdde57099e3a07bda1b0776a398b24497 (patch)
treec1d1e260e0a7b76dc8f1b562b5cd2eaa537ad91c
parent9fc569d67f5e07941ed27d16148df8ebfad0a97b (diff)
downloadrust-5d76ec9cdde57099e3a07bda1b0776a398b24497.tar.gz
rust-5d76ec9cdde57099e3a07bda1b0776a398b24497.zip
merge float tests into one
-rw-r--r--src/tools/miri/tests/pass/float.rs67
-rw-r--r--src/tools/miri/tests/pass/float_fast_math.rs34
-rw-r--r--src/tools/miri/tests/pass/intrinsics/float_algebraic_math.rs32
3 files changed, 67 insertions, 66 deletions
diff --git a/src/tools/miri/tests/pass/float.rs b/src/tools/miri/tests/pass/float.rs
index 1bb44d56bf6..8aea9b3e6f9 100644
--- a/src/tools/miri/tests/pass/float.rs
+++ b/src/tools/miri/tests/pass/float.rs
@@ -1,5 +1,6 @@
 #![feature(stmt_expr_attributes)]
 #![feature(float_gamma)]
+#![feature(core_intrinsics)]
 #![allow(arithmetic_overflow)]
 
 use std::fmt::Debug;
@@ -22,6 +23,8 @@ fn main() {
     rounding();
     mul_add();
     libm();
+    test_fast();
+    test_algebraic();
 }
 
 // Helper function to avoid promotion so that this tests "run-time" casts, not CTFE.
@@ -751,3 +754,67 @@ pub fn libm() {
     assert_approx_eq!(val, (2.0 * f64::consts::PI.sqrt()).ln());
     assert_eq!(sign, -1);
 }
+
+fn test_fast() {
+    use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
+
+    #[inline(never)]
+    pub fn test_operations_f64(a: f64, b: f64) {
+        // make sure they all map to the correct operation
+        unsafe {
+            assert_eq!(fadd_fast(a, b), a + b);
+            assert_eq!(fsub_fast(a, b), a - b);
+            assert_eq!(fmul_fast(a, b), a * b);
+            assert_eq!(fdiv_fast(a, b), a / b);
+            assert_eq!(frem_fast(a, b), a % b);
+        }
+    }
+
+    #[inline(never)]
+    pub fn test_operations_f32(a: f32, b: f32) {
+        // make sure they all map to the correct operation
+        unsafe {
+            assert_eq!(fadd_fast(a, b), a + b);
+            assert_eq!(fsub_fast(a, b), a - b);
+            assert_eq!(fmul_fast(a, b), a * b);
+            assert_eq!(fdiv_fast(a, b), a / b);
+            assert_eq!(frem_fast(a, b), a % b);
+        }
+    }
+
+    test_operations_f64(1., 2.);
+    test_operations_f64(10., 5.);
+    test_operations_f32(11., 2.);
+    test_operations_f32(10., 15.);
+}
+
+fn test_algebraic() {
+    use std::intrinsics::{
+        fadd_algebraic, fdiv_algebraic, fmul_algebraic, frem_algebraic, fsub_algebraic,
+    };
+
+    #[inline(never)]
+    pub fn test_operations_f64(a: f64, b: f64) {
+        // make sure they all map to the correct operation
+        assert_eq!(fadd_algebraic(a, b), a + b);
+        assert_eq!(fsub_algebraic(a, b), a - b);
+        assert_eq!(fmul_algebraic(a, b), a * b);
+        assert_eq!(fdiv_algebraic(a, b), a / b);
+        assert_eq!(frem_algebraic(a, b), a % b);
+    }
+
+    #[inline(never)]
+    pub fn test_operations_f32(a: f32, b: f32) {
+        // make sure they all map to the correct operation
+        assert_eq!(fadd_algebraic(a, b), a + b);
+        assert_eq!(fsub_algebraic(a, b), a - b);
+        assert_eq!(fmul_algebraic(a, b), a * b);
+        assert_eq!(fdiv_algebraic(a, b), a / b);
+        assert_eq!(frem_algebraic(a, b), a % b);
+    }
+
+    test_operations_f64(1., 2.);
+    test_operations_f64(10., 5.);
+    test_operations_f32(11., 2.);
+    test_operations_f32(10., 15.);
+}
diff --git a/src/tools/miri/tests/pass/float_fast_math.rs b/src/tools/miri/tests/pass/float_fast_math.rs
deleted file mode 100644
index 52d985667df..00000000000
--- a/src/tools/miri/tests/pass/float_fast_math.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
-
-#[inline(never)]
-pub fn test_operations_f64(a: f64, b: f64) {
-    // make sure they all map to the correct operation
-    unsafe {
-        assert_eq!(fadd_fast(a, b), a + b);
-        assert_eq!(fsub_fast(a, b), a - b);
-        assert_eq!(fmul_fast(a, b), a * b);
-        assert_eq!(fdiv_fast(a, b), a / b);
-        assert_eq!(frem_fast(a, b), a % b);
-    }
-}
-
-#[inline(never)]
-pub fn test_operations_f32(a: f32, b: f32) {
-    // make sure they all map to the correct operation
-    unsafe {
-        assert_eq!(fadd_fast(a, b), a + b);
-        assert_eq!(fsub_fast(a, b), a - b);
-        assert_eq!(fmul_fast(a, b), a * b);
-        assert_eq!(fdiv_fast(a, b), a / b);
-        assert_eq!(frem_fast(a, b), a % b);
-    }
-}
-
-fn main() {
-    test_operations_f64(1., 2.);
-    test_operations_f64(10., 5.);
-    test_operations_f32(11., 2.);
-    test_operations_f32(10., 15.);
-}
diff --git a/src/tools/miri/tests/pass/intrinsics/float_algebraic_math.rs b/src/tools/miri/tests/pass/intrinsics/float_algebraic_math.rs
deleted file mode 100644
index f6f083f7b5f..00000000000
--- a/src/tools/miri/tests/pass/intrinsics/float_algebraic_math.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics::{
-    fadd_algebraic, fdiv_algebraic, fmul_algebraic, frem_algebraic, fsub_algebraic,
-};
-
-#[inline(never)]
-pub fn test_operations_f64(a: f64, b: f64) {
-    // make sure they all map to the correct operation
-    assert_eq!(fadd_algebraic(a, b), a + b);
-    assert_eq!(fsub_algebraic(a, b), a - b);
-    assert_eq!(fmul_algebraic(a, b), a * b);
-    assert_eq!(fdiv_algebraic(a, b), a / b);
-    assert_eq!(frem_algebraic(a, b), a % b);
-}
-
-#[inline(never)]
-pub fn test_operations_f32(a: f32, b: f32) {
-    // make sure they all map to the correct operation
-    assert_eq!(fadd_algebraic(a, b), a + b);
-    assert_eq!(fsub_algebraic(a, b), a - b);
-    assert_eq!(fmul_algebraic(a, b), a * b);
-    assert_eq!(fdiv_algebraic(a, b), a / b);
-    assert_eq!(frem_algebraic(a, b), a % b);
-}
-
-fn main() {
-    test_operations_f64(1., 2.);
-    test_operations_f64(10., 5.);
-    test_operations_f32(11., 2.);
-    test_operations_f32(10., 15.);
-}