test out of range condition using f64

to avoid imprecision due to rounding to f32
This commit is contained in:
Jorge Aparicio 2017-04-08 10:18:19 -05:00
parent 4c556dc9e7
commit 109c33ed0a

View File

@ -200,16 +200,16 @@ mod tests {
fn __fixsfsi(f: extern "C" fn(f32) -> i32,
a: F32)
-> Option<I32> {
if a.0 > (i32::max_value() as f32) ||
a.0 < (i32::min_value() as f32) || a.0.is_nan() {
if (a.0 as f64) > (i32::max_value() as f64) ||
(a.0 as f64) < (i32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I32(f(a.0))) }
}
fn __fixsfdi(f: extern "C" fn(f32) -> i64,
a: F32)
-> Option<I64> {
if a.0 > (i64::max_value() as f32) ||
a.0 < (i64::min_value() as f32) || a.0.is_nan() {
if (a.0 as f64) > (i64::max_value() as f64) ||
(a.0 as f64) < (i64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I64(f(a.0))) }
}
@ -233,16 +233,16 @@ mod tests {
fn __fixunssfsi(f: extern "C" fn(f32) -> u32,
a: F32)
-> Option<U32> {
if a.0 > (u32::max_value() as f32) ||
a.0 < (u32::min_value() as f32) || a.0.is_nan() {
if (a.0 as f64) > (u32::max_value() as f64) ||
(a.0 as f64) < (u32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U32(f(a.0))) }
}
fn __fixunssfdi(f: extern "C" fn(f32) -> u64,
a: F32)
-> Option<U64> {
if a.0 > (u64::max_value() as f32) ||
a.0 < (u64::min_value() as f32) || a.0.is_nan() {
if (a.0 as f64) > (u64::max_value() as f64) ||
(a.0 as f64) < (u64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U64(f(a.0))) }
}