about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-29 07:25:22 +0200
committerRalf Jung <post@ralfj.de>2023-09-29 07:33:45 +0200
commit2f7fdd1ee9f0473ef893fe79329429406f193893 (patch)
tree28d73b169505658977000c5d2e7a2f905a87dd6e /src
parent6ef11ddc3bdf4b42c715450d2d8e163e39561c32 (diff)
downloadrust-2f7fdd1ee9f0473ef893fe79329429406f193893.tar.gz
rust-2f7fdd1ee9f0473ef893fe79329429406f193893.zip
add tests for '%' sign on floats
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/tests/pass/float.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/float.rs b/src/tools/miri/tests/pass/float.rs
index fee5ca44ffb..70c64485fe9 100644
--- a/src/tools/miri/tests/pass/float.rs
+++ b/src/tools/miri/tests/pass/float.rs
@@ -168,6 +168,16 @@ fn basic() {
     let x: u32 = unsafe { std::mem::transmute(42.0_f32) };
     let y: f32 = unsafe { std::mem::transmute(x) };
     assert_eq(y, 42.0_f32);
+
+    // `%` sign behavior, some of this used to be buggy
+    assert!((black_box(1.0f32) % 1.0).is_sign_positive());
+    assert!((black_box(1.0f32) % -1.0).is_sign_positive());
+    assert!((black_box(-1.0f32) % 1.0).is_sign_negative());
+    assert!((black_box(-1.0f32) % -1.0).is_sign_negative());
+    assert!((black_box(1.0f64) % 1.0).is_sign_positive());
+    assert!((black_box(1.0f64) % -1.0).is_sign_positive());
+    assert!((black_box(-1.0f64) % 1.0).is_sign_negative());
+    assert!((black_box(-1.0f64) % -1.0).is_sign_negative());
 }
 
 /// Many of these test values are taken from