Skip to content

Commit a9e609c

Browse files
committed
add tests for '%' sign on floats
1 parent 0ead204 commit a9e609c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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)