Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2f7fdd1

Browse files
committed
add tests for '%' sign on floats
1 parent 6ef11dd commit 2f7fdd1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/tools/miri/tests/pass/float.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ fn basic() {
168168
let x: u32 = unsafe { std::mem::transmute(42.0_f32) };
169169
let y: f32 = unsafe { std::mem::transmute(x) };
170170
assert_eq(y, 42.0_f32);
171+
172+
// `%` sign behavior, some of this used to be buggy
173+
assert!((black_box(1.0f32) % 1.0).is_sign_positive());
174+
assert!((black_box(1.0f32) % -1.0).is_sign_positive());
175+
assert!((black_box(-1.0f32) % 1.0).is_sign_negative());
176+
assert!((black_box(-1.0f32) % -1.0).is_sign_negative());
177+
assert!((black_box(1.0f64) % 1.0).is_sign_positive());
178+
assert!((black_box(1.0f64) % -1.0).is_sign_positive());
179+
assert!((black_box(-1.0f64) % 1.0).is_sign_negative());
180+
assert!((black_box(-1.0f64) % -1.0).is_sign_negative());
171181
}
172182

173183
/// Many of these test values are taken from

0 commit comments

Comments
 (0)