@@ -5,6 +5,8 @@ use core::ops::{Add, Div, Mul, Sub};
55use std:: f128:: consts;
66use std:: num:: FpCategory as Fp ;
77
8+ use super :: { assert_approx_eq, assert_biteq} ;
9+
810// Note these tolerances make sense around zero, but not for more extreme exponents.
911
1012/// Default tolerances. Works for values that should be near precise but not exact. Roughly
@@ -53,34 +55,6 @@ fn test_num_f128() {
5355// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
5456// the intrinsics.
5557
56- #[ test]
57- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
58- fn test_min_nan ( ) {
59- assert_biteq ! ( f128:: NAN . min( 2.0 ) , 2.0 ) ;
60- assert_biteq ! ( 2.0f128 . min( f128:: NAN ) , 2.0 ) ;
61- }
62-
63- #[ test]
64- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
65- fn test_max_nan ( ) {
66- assert_biteq ! ( f128:: NAN . max( 2.0 ) , 2.0 ) ;
67- assert_biteq ! ( 2.0f128 . max( f128:: NAN ) , 2.0 ) ;
68- }
69-
70- #[ test]
71- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
72- fn test_minimum ( ) {
73- assert ! ( f128:: NAN . minimum( 2.0 ) . is_nan( ) ) ;
74- assert ! ( 2.0f128 . minimum( f128:: NAN ) . is_nan( ) ) ;
75- }
76-
77- #[ test]
78- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
79- fn test_maximum ( ) {
80- assert ! ( f128:: NAN . maximum( 2.0 ) . is_nan( ) ) ;
81- assert ! ( 2.0f128 . maximum( f128:: NAN ) . is_nan( ) ) ;
82- }
83-
8458#[ test]
8559fn test_nan ( ) {
8660 let nan: f128 = f128:: NAN ;
@@ -232,98 +206,6 @@ fn test_classify() {
232206 assert_eq ! ( 1e-4932f128 . classify( ) , Fp :: Subnormal ) ;
233207}
234208
235- #[ test]
236- #[ cfg( target_has_reliable_f128_math) ]
237- fn test_floor ( ) {
238- assert_biteq ! ( 1.0f128 . floor( ) , 1.0f128 ) ;
239- assert_biteq ! ( 1.3f128 . floor( ) , 1.0f128 ) ;
240- assert_biteq ! ( 1.5f128 . floor( ) , 1.0f128 ) ;
241- assert_biteq ! ( 1.7f128 . floor( ) , 1.0f128 ) ;
242- assert_biteq ! ( 0.0f128 . floor( ) , 0.0f128 ) ;
243- assert_biteq ! ( ( -0.0f128 ) . floor( ) , -0.0f128 ) ;
244- assert_biteq ! ( ( -1.0f128 ) . floor( ) , -1.0f128 ) ;
245- assert_biteq ! ( ( -1.3f128 ) . floor( ) , -2.0f128 ) ;
246- assert_biteq ! ( ( -1.5f128 ) . floor( ) , -2.0f128 ) ;
247- assert_biteq ! ( ( -1.7f128 ) . floor( ) , -2.0f128 ) ;
248- }
249-
250- #[ test]
251- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
252- fn test_ceil ( ) {
253- assert_biteq ! ( 1.0f128 . ceil( ) , 1.0f128 ) ;
254- assert_biteq ! ( 1.3f128 . ceil( ) , 2.0f128 ) ;
255- assert_biteq ! ( 1.5f128 . ceil( ) , 2.0f128 ) ;
256- assert_biteq ! ( 1.7f128 . ceil( ) , 2.0f128 ) ;
257- assert_biteq ! ( 0.0f128 . ceil( ) , 0.0f128 ) ;
258- assert_biteq ! ( ( -0.0f128 ) . ceil( ) , -0.0f128 ) ;
259- assert_biteq ! ( ( -1.0f128 ) . ceil( ) , -1.0f128 ) ;
260- assert_biteq ! ( ( -1.3f128 ) . ceil( ) , -1.0f128 ) ;
261- assert_biteq ! ( ( -1.5f128 ) . ceil( ) , -1.0f128 ) ;
262- assert_biteq ! ( ( -1.7f128 ) . ceil( ) , -1.0f128 ) ;
263- }
264-
265- #[ test]
266- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
267- fn test_round ( ) {
268- assert_biteq ! ( 2.5f128 . round( ) , 3.0f128 ) ;
269- assert_biteq ! ( 1.0f128 . round( ) , 1.0f128 ) ;
270- assert_biteq ! ( 1.3f128 . round( ) , 1.0f128 ) ;
271- assert_biteq ! ( 1.5f128 . round( ) , 2.0f128 ) ;
272- assert_biteq ! ( 1.7f128 . round( ) , 2.0f128 ) ;
273- assert_biteq ! ( 0.0f128 . round( ) , 0.0f128 ) ;
274- assert_biteq ! ( ( -0.0f128 ) . round( ) , -0.0f128 ) ;
275- assert_biteq ! ( ( -1.0f128 ) . round( ) , -1.0f128 ) ;
276- assert_biteq ! ( ( -1.3f128 ) . round( ) , -1.0f128 ) ;
277- assert_biteq ! ( ( -1.5f128 ) . round( ) , -2.0f128 ) ;
278- assert_biteq ! ( ( -1.7f128 ) . round( ) , -2.0f128 ) ;
279- }
280-
281- #[ test]
282- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
283- fn test_round_ties_even ( ) {
284- assert_biteq ! ( 2.5f128 . round_ties_even( ) , 2.0f128 ) ;
285- assert_biteq ! ( 1.0f128 . round_ties_even( ) , 1.0f128 ) ;
286- assert_biteq ! ( 1.3f128 . round_ties_even( ) , 1.0f128 ) ;
287- assert_biteq ! ( 1.5f128 . round_ties_even( ) , 2.0f128 ) ;
288- assert_biteq ! ( 1.7f128 . round_ties_even( ) , 2.0f128 ) ;
289- assert_biteq ! ( 0.0f128 . round_ties_even( ) , 0.0f128 ) ;
290- assert_biteq ! ( ( -0.0f128 ) . round_ties_even( ) , -0.0f128 ) ;
291- assert_biteq ! ( ( -1.0f128 ) . round_ties_even( ) , -1.0f128 ) ;
292- assert_biteq ! ( ( -1.3f128 ) . round_ties_even( ) , -1.0f128 ) ;
293- assert_biteq ! ( ( -1.5f128 ) . round_ties_even( ) , -2.0f128 ) ;
294- assert_biteq ! ( ( -1.7f128 ) . round_ties_even( ) , -2.0f128 ) ;
295- }
296-
297- #[ test]
298- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
299- fn test_trunc ( ) {
300- assert_biteq ! ( 1.0f128 . trunc( ) , 1.0f128 ) ;
301- assert_biteq ! ( 1.3f128 . trunc( ) , 1.0f128 ) ;
302- assert_biteq ! ( 1.5f128 . trunc( ) , 1.0f128 ) ;
303- assert_biteq ! ( 1.7f128 . trunc( ) , 1.0f128 ) ;
304- assert_biteq ! ( 0.0f128 . trunc( ) , 0.0f128 ) ;
305- assert_biteq ! ( ( -0.0f128 ) . trunc( ) , -0.0f128 ) ;
306- assert_biteq ! ( ( -1.0f128 ) . trunc( ) , -1.0f128 ) ;
307- assert_biteq ! ( ( -1.3f128 ) . trunc( ) , -1.0f128 ) ;
308- assert_biteq ! ( ( -1.5f128 ) . trunc( ) , -1.0f128 ) ;
309- assert_biteq ! ( ( -1.7f128 ) . trunc( ) , -1.0f128 ) ;
310- }
311-
312- #[ test]
313- #[ cfg( any( miri, target_has_reliable_f128_math) ) ]
314- fn test_fract ( ) {
315- assert_biteq ! ( 1.0f128 . fract( ) , 0.0f128 ) ;
316- assert_biteq ! ( 1.3f128 . fract( ) , 0.300000000000000000000000000000000039f128 ) ;
317- assert_biteq ! ( 1.5f128 . fract( ) , 0.5f128 ) ;
318- assert_biteq ! ( 1.7f128 . fract( ) , 0.7f128 ) ;
319- assert_biteq ! ( 0.0f128 . fract( ) , 0.0f128 ) ;
320- assert_biteq ! ( ( -0.0f128 ) . fract( ) , 0.0f128 ) ;
321- assert_biteq ! ( ( -1.0f128 ) . fract( ) , 0.0f128 ) ;
322- assert_biteq ! ( ( -1.3f128 ) . fract( ) , -0.300000000000000000000000000000000039f128 ) ;
323- assert_biteq ! ( ( -1.5f128 ) . fract( ) , -0.5f128 ) ;
324- assert_biteq ! ( ( -1.7f128 ) . fract( ) , -0.699999999999999999999999999999999961f128 ) ;
325- }
326-
327209#[ test]
328210#[ cfg( any( miri, target_has_reliable_f128_math) ) ]
329211fn test_abs ( ) {
0 commit comments