File tree Expand file tree Collapse file tree 5 files changed +23
-71
lines changed Expand file tree Collapse file tree 5 files changed +23
-71
lines changed Original file line number Diff line number Diff line change 22#![ cfg( target_has_reliable_f128) ]
33
44use std:: f128:: consts;
5- use std:: num:: FpCategory as Fp ;
65
76use super :: { assert_approx_eq, assert_biteq} ;
87
@@ -40,23 +39,6 @@ const NAN_MASK2: u128 = 0x00005555555555555555555555555555;
4039// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
4140// the intrinsics.
4241
43- #[ test]
44- fn test_classify ( ) {
45- let nan: f128 = f128:: NAN ;
46- let inf: f128 = f128:: INFINITY ;
47- let neg_inf: f128 = f128:: NEG_INFINITY ;
48- let zero: f128 = 0.0f128 ;
49- let neg_zero: f128 = -0.0 ;
50- assert_eq ! ( nan. classify( ) , Fp :: Nan ) ;
51- assert_eq ! ( inf. classify( ) , Fp :: Infinite ) ;
52- assert_eq ! ( neg_inf. classify( ) , Fp :: Infinite ) ;
53- assert_eq ! ( zero. classify( ) , Fp :: Zero ) ;
54- assert_eq ! ( neg_zero. classify( ) , Fp :: Zero ) ;
55- assert_eq ! ( 1 f128. classify( ) , Fp :: Normal ) ;
56- assert_eq ! ( 1e-4931f128 . classify( ) , Fp :: Normal ) ;
57- assert_eq ! ( 1e-4932f128 . classify( ) , Fp :: Subnormal ) ;
58- }
59-
6042#[ test]
6143#[ cfg( any( miri, target_has_reliable_f128_math) ) ]
6244fn test_abs ( ) {
Original file line number Diff line number Diff line change 22#![ cfg( target_has_reliable_f16) ]
33
44use std:: f16:: consts;
5- use std:: num:: FpCategory as Fp ;
65
76use super :: { assert_approx_eq, assert_biteq} ;
87
@@ -46,23 +45,6 @@ const NAN_MASK2: u16 = 0x0155;
4645// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
4746// the intrinsics.
4847
49- #[ test]
50- fn test_classify ( ) {
51- let nan: f16 = f16:: NAN ;
52- let inf: f16 = f16:: INFINITY ;
53- let neg_inf: f16 = f16:: NEG_INFINITY ;
54- let zero: f16 = 0.0f16 ;
55- let neg_zero: f16 = -0.0 ;
56- assert_eq ! ( nan. classify( ) , Fp :: Nan ) ;
57- assert_eq ! ( inf. classify( ) , Fp :: Infinite ) ;
58- assert_eq ! ( neg_inf. classify( ) , Fp :: Infinite ) ;
59- assert_eq ! ( zero. classify( ) , Fp :: Zero ) ;
60- assert_eq ! ( neg_zero. classify( ) , Fp :: Zero ) ;
61- assert_eq ! ( 1 f16. classify( ) , Fp :: Normal ) ;
62- assert_eq ! ( 1e-4f16 . classify( ) , Fp :: Normal ) ;
63- assert_eq ! ( 1e-5f16 . classify( ) , Fp :: Subnormal ) ;
64- }
65-
6648#[ test]
6749#[ cfg( any( miri, target_has_reliable_f16_math) ) ]
6850fn test_abs ( ) {
Original file line number Diff line number Diff line change 11use core:: f32;
22use core:: f32:: consts;
3- use core:: num:: FpCategory as Fp ;
43
54use super :: { assert_approx_eq, assert_biteq} ;
65
@@ -30,23 +29,6 @@ const NAN_MASK2: u32 = 0x0055_5555;
3029/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
3130const APPROX_DELTA : f32 = if cfg ! ( miri) { 1e-4 } else { 1e-6 } ;
3231
33- #[ test]
34- fn test_classify ( ) {
35- let nan: f32 = f32:: NAN ;
36- let inf: f32 = f32:: INFINITY ;
37- let neg_inf: f32 = f32:: NEG_INFINITY ;
38- let zero: f32 = 0.0f32 ;
39- let neg_zero: f32 = -0.0 ;
40- assert_eq ! ( nan. classify( ) , Fp :: Nan ) ;
41- assert_eq ! ( inf. classify( ) , Fp :: Infinite ) ;
42- assert_eq ! ( neg_inf. classify( ) , Fp :: Infinite ) ;
43- assert_eq ! ( zero. classify( ) , Fp :: Zero ) ;
44- assert_eq ! ( neg_zero. classify( ) , Fp :: Zero ) ;
45- assert_eq ! ( 1f32 . classify( ) , Fp :: Normal ) ;
46- assert_eq ! ( 1e-37f32 . classify( ) , Fp :: Normal ) ;
47- assert_eq ! ( 1e-38f32 . classify( ) , Fp :: Subnormal ) ;
48- }
49-
5032#[ test]
5133fn test_abs ( ) {
5234 assert_biteq ! ( f32 :: INFINITY . abs( ) , f32 :: INFINITY ) ;
Original file line number Diff line number Diff line change 11use core:: f64;
22use core:: f64:: consts;
3- use core:: num:: FpCategory as Fp ;
43
54use super :: { assert_approx_eq, assert_biteq} ;
65
@@ -25,22 +24,6 @@ const NAN_MASK1: u64 = 0x000a_aaaa_aaaa_aaaa;
2524/// Second pattern over the mantissa
2625const NAN_MASK2 : u64 = 0x0005_5555_5555_5555 ;
2726
28- #[ test]
29- fn test_classify ( ) {
30- let nan: f64 = f64:: NAN ;
31- let inf: f64 = f64:: INFINITY ;
32- let neg_inf: f64 = f64:: NEG_INFINITY ;
33- let zero: f64 = 0.0f64 ;
34- let neg_zero: f64 = -0.0 ;
35- assert_eq ! ( nan. classify( ) , Fp :: Nan ) ;
36- assert_eq ! ( inf. classify( ) , Fp :: Infinite ) ;
37- assert_eq ! ( neg_inf. classify( ) , Fp :: Infinite ) ;
38- assert_eq ! ( zero. classify( ) , Fp :: Zero ) ;
39- assert_eq ! ( neg_zero. classify( ) , Fp :: Zero ) ;
40- assert_eq ! ( 1e-307f64 . classify( ) , Fp :: Normal ) ;
41- assert_eq ! ( 1e-308f64 . classify( ) , Fp :: Subnormal ) ;
42- }
43-
4427#[ test]
4528fn test_abs ( ) {
4629 assert_biteq ! ( f64 :: INFINITY . abs( ) , f64 :: INFINITY ) ;
Original file line number Diff line number Diff line change @@ -483,6 +483,29 @@ float_test! {
483483 }
484484}
485485
486+ float_test ! {
487+ name: classify,
488+ attrs: {
489+ f16: #[ cfg( any( miri, target_has_reliable_f16) ) ] ,
490+ } ,
491+ test<Float > {
492+ let nan: Float = Float :: NAN ;
493+ let inf: Float = Float :: INFINITY ;
494+ let neg_inf: Float = Float :: NEG_INFINITY ;
495+ let zero: Float = 0.0 ;
496+ let neg_zero: Float = -0.0 ;
497+ let one: Float = 1.0 ;
498+ assert!( matches!( nan. classify( ) , Fp :: Nan ) ) ;
499+ assert!( matches!( inf. classify( ) , Fp :: Infinite ) ) ;
500+ assert!( matches!( neg_inf. classify( ) , Fp :: Infinite ) ) ;
501+ assert!( matches!( zero. classify( ) , Fp :: Zero ) ) ;
502+ assert!( matches!( neg_zero. classify( ) , Fp :: Zero ) ) ;
503+ assert!( matches!( one. classify( ) , Fp :: Normal ) ) ;
504+ assert!( matches!( Float :: MIN_POSITIVE_NORMAL . classify( ) , Fp :: Normal ) ) ;
505+ assert!( matches!( Float :: MAX_SUBNORMAL . classify( ) , Fp :: Subnormal ) ) ;
506+ }
507+ }
508+
486509float_test ! {
487510 name: min,
488511 attrs: {
You can’t perform that action at this time.
0 commit comments