Skip to content

Commit 33eb565

Browse files
committed
ldexp: test overflow behavior
1 parent 0743ed6 commit 33eb565

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/run-pass/intrinsics-math.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ macro_rules! assert_approx_eq {
1616
})
1717
}
1818

19+
fn ldexp(a: f64, b: i32) -> f64 {
20+
extern {
21+
fn ldexp(x: f64, n: i32) -> f64;
22+
}
23+
unsafe { ldexp(a, b) }
24+
}
25+
1926
pub fn main() {
2027
use std::f32;
2128
use std::f64;
@@ -88,8 +95,7 @@ pub fn main() {
8895
assert_eq!(3.3_f32.round(), 3.0);
8996
assert_eq!(3.3_f64.round(), 3.0);
9097

91-
extern {
92-
fn ldexp(x: f64, n: i32) -> f64;
93-
}
94-
unsafe { assert_approx_eq!(ldexp(0.65f64, 3i32), 5.2f64); }
98+
assert_eq!(ldexp(0.65f64, 3i32), 5.2f64);
99+
assert_eq!(ldexp(1.42, 0xFFFF), f64::INFINITY);
100+
assert_eq!(ldexp(1.42, -0xFFFF), 0f64);
95101
}

0 commit comments

Comments
 (0)