Skip to content

Commit ef0b999

Browse files
author
Robin Kruppe
committed
Disable u128 <-> float tests on emscripten
1 parent ce46649 commit ef0b999

File tree

1 file changed

+39
-29
lines changed

1 file changed

+39
-29
lines changed

src/test/run-pass/saturating-float-casts.rs

+39-29
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
extern crate test;
1616

1717
use std::{f32, f64};
18-
use std::{u8, i8, u16, i16, u32, i32, u64, i64, u128, i128};
18+
use std::{u8, i8, u16, i16, u32, i32, u64, i64};
19+
#[cfg(not(target_os="emscripten"))]
20+
use std::{u128, i128};
1921
use test::black_box;
2022

2123
macro_rules! test {
@@ -92,8 +94,13 @@ macro_rules! fptoui_tests {
9294
}
9395

9496
pub fn main() {
95-
common_fptoi_tests!(f* -> i8 i16 i32 i64 i128 u8 u16 u32 u64 u128);
96-
fptoui_tests!(f* -> u8 u16 u32 u64 u128);
97+
common_fptoi_tests!(f* -> i8 i16 i32 i64 u8 u16 u32 u64);
98+
fptoui_tests!(f* -> u8 u16 u32 u64);
99+
// FIXME emscripten does not support i128
100+
#[cfg(not(target_os="emscripten"))] {
101+
common_fptoi_tests!(f* -> i128 u128);
102+
fptoui_tests!(f* -> u128);
103+
}
97104

98105
// The following tests cover edge cases for some integer types.
99106

@@ -125,30 +132,33 @@ pub fn main() {
125132
test!(4294967296., f* -> u32, 4294967295);
126133

127134
// # u128
128-
// float->int:
129-
test_c!(f32::MAX, f32 -> u128, 0xffffff00000000000000000000000000);
130-
// nextDown(f32::MAX) = 2^128 - 2 * 2^104
131-
const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.;
132-
test_c!(SECOND_LARGEST_F32, f32 -> u128, 0xfffffe00000000000000000000000000);
133-
134-
// int->float:
135-
// f32::MAX - 0.5 ULP and smaller should be rounded down
136-
test_c!(0xfffffe00000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
137-
test_c!(0xfffffe7fffffffffffffffffffffffff, u128 -> f32, SECOND_LARGEST_F32);
138-
test_c!(0xfffffe80000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
139-
// numbers within < 0.5 ULP of f32::MAX it should be rounded to f32::MAX
140-
test_c!(0xfffffe80000000000000000000000001, u128 -> f32, f32::MAX);
141-
test_c!(0xfffffeffffffffffffffffffffffffff, u128 -> f32, f32::MAX);
142-
test_c!(0xffffff00000000000000000000000000, u128 -> f32, f32::MAX);
143-
test_c!(0xffffff00000000000000000000000001, u128 -> f32, f32::MAX);
144-
test_c!(0xffffff7fffffffffffffffffffffffff, u128 -> f32, f32::MAX);
145-
// f32::MAX + 0.5 ULP and greater should be rounded to infinity
146-
test_c!(0xffffff80000000000000000000000000, u128 -> f32, f32::INFINITY);
147-
test_c!(0xffffff80000000f00000000000000000, u128 -> f32, f32::INFINITY);
148-
test_c!(0xffffff87ffffffffffffffff00000001, u128 -> f32, f32::INFINITY);
149-
150-
// u128->f64 should not be affected by the u128->f32 checks
151-
test_c!(0xffffff80000000000000000000000000, u128 -> f64,
152-
340282356779733661637539395458142568448.0);
153-
test_c!(u128::MAX, u128 -> f64, 340282366920938463463374607431768211455.0);
135+
#[cfg(not(target_os="emscripten"))]
136+
{
137+
// float->int:
138+
test_c!(f32::MAX, f32 -> u128, 0xffffff00000000000000000000000000);
139+
// nextDown(f32::MAX) = 2^128 - 2 * 2^104
140+
const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.;
141+
test_c!(SECOND_LARGEST_F32, f32 -> u128, 0xfffffe00000000000000000000000000);
142+
143+
// int->float:
144+
// f32::MAX - 0.5 ULP and smaller should be rounded down
145+
test_c!(0xfffffe00000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
146+
test_c!(0xfffffe7fffffffffffffffffffffffff, u128 -> f32, SECOND_LARGEST_F32);
147+
test_c!(0xfffffe80000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32);
148+
// numbers within < 0.5 ULP of f32::MAX it should be rounded to f32::MAX
149+
test_c!(0xfffffe80000000000000000000000001, u128 -> f32, f32::MAX);
150+
test_c!(0xfffffeffffffffffffffffffffffffff, u128 -> f32, f32::MAX);
151+
test_c!(0xffffff00000000000000000000000000, u128 -> f32, f32::MAX);
152+
test_c!(0xffffff00000000000000000000000001, u128 -> f32, f32::MAX);
153+
test_c!(0xffffff7fffffffffffffffffffffffff, u128 -> f32, f32::MAX);
154+
// f32::MAX + 0.5 ULP and greater should be rounded to infinity
155+
test_c!(0xffffff80000000000000000000000000, u128 -> f32, f32::INFINITY);
156+
test_c!(0xffffff80000000f00000000000000000, u128 -> f32, f32::INFINITY);
157+
test_c!(0xffffff87ffffffffffffffff00000001, u128 -> f32, f32::INFINITY);
158+
159+
// u128->f64 should not be affected by the u128->f32 checks
160+
test_c!(0xffffff80000000000000000000000000, u128 -> f64,
161+
340282356779733661637539395458142568448.0);
162+
test_c!(u128::MAX, u128 -> f64, 340282366920938463463374607431768211455.0);
163+
}
154164
}

0 commit comments

Comments
 (0)