File tree Expand file tree Collapse file tree 5 files changed +22
-71
lines changed
library/coretests/tests/floats Expand file tree Collapse file tree 5 files changed +22
-71
lines changed Original file line number Diff line number Diff line change 2
2
#![ cfg( target_has_reliable_f128) ]
3
3
4
4
use std:: f128:: consts;
5
- use std:: num:: FpCategory as Fp ;
6
5
7
6
use super :: { assert_approx_eq, assert_biteq} ;
8
7
@@ -40,23 +39,6 @@ const NAN_MASK2: u128 = 0x00005555555555555555555555555555;
40
39
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
41
40
// the intrinsics.
42
41
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
-
60
42
#[ test]
61
43
#[ cfg( any( miri, target_has_reliable_f128_math) ) ]
62
44
fn test_abs ( ) {
Original file line number Diff line number Diff line change 2
2
#![ cfg( target_has_reliable_f16) ]
3
3
4
4
use std:: f16:: consts;
5
- use std:: num:: FpCategory as Fp ;
6
5
7
6
use super :: { assert_approx_eq, assert_biteq} ;
8
7
@@ -46,23 +45,6 @@ const NAN_MASK2: u16 = 0x0155;
46
45
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
47
46
// the intrinsics.
48
47
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
-
66
48
#[ test]
67
49
#[ cfg( any( miri, target_has_reliable_f16_math) ) ]
68
50
fn test_abs ( ) {
Original file line number Diff line number Diff line change 1
1
use core:: f32;
2
2
use core:: f32:: consts;
3
- use core:: num:: FpCategory as Fp ;
4
3
5
4
use super :: { assert_approx_eq, assert_biteq} ;
6
5
@@ -30,23 +29,6 @@ const NAN_MASK2: u32 = 0x0055_5555;
30
29
/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
31
30
const APPROX_DELTA : f32 = if cfg ! ( miri) { 1e-4 } else { 1e-6 } ;
32
31
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
-
50
32
#[ test]
51
33
fn test_abs ( ) {
52
34
assert_biteq ! ( f32 :: INFINITY . abs( ) , f32 :: INFINITY ) ;
Original file line number Diff line number Diff line change 1
1
use core:: f64;
2
2
use core:: f64:: consts;
3
- use core:: num:: FpCategory as Fp ;
4
3
5
4
use super :: { assert_approx_eq, assert_biteq} ;
6
5
@@ -25,22 +24,6 @@ const NAN_MASK1: u64 = 0x000a_aaaa_aaaa_aaaa;
25
24
/// Second pattern over the mantissa
26
25
const NAN_MASK2 : u64 = 0x0005_5555_5555_5555 ;
27
26
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
-
44
27
#[ test]
45
28
fn test_abs ( ) {
46
29
assert_biteq ! ( f64 :: INFINITY . abs( ) , f64 :: INFINITY ) ;
Original file line number Diff line number Diff line change @@ -492,6 +492,28 @@ float_test! {
492
492
}
493
493
}
494
494
495
+ float_test ! {
496
+ name: classify,
497
+ attrs: {
498
+ f16: #[ cfg( any( miri, target_has_reliable_f16) ) ] ,
499
+ } ,
500
+ test<Float > {
501
+ let nan: Float = Float :: NAN ;
502
+ let inf: Float = Float :: INFINITY ;
503
+ let neg_inf: Float = Float :: NEG_INFINITY ;
504
+ let zero: Float = 0.0 ;
505
+ let neg_zero: Float = -0.0 ;
506
+ assert!( matches!( nan. classify( ) , Fp :: Nan ) ) ;
507
+ assert!( matches!( inf. classify( ) , Fp :: Infinite ) ) ;
508
+ assert!( matches!( neg_inf. classify( ) , Fp :: Infinite ) ) ;
509
+ assert!( matches!( zero. classify( ) , Fp :: Zero ) ) ;
510
+ assert!( matches!( neg_zero. classify( ) , Fp :: Zero ) ) ;
511
+ assert!( matches!( 1f32 . classify( ) , Fp :: Normal ) ) ;
512
+ assert!( matches!( Float :: SMALL_NORMAL . classify( ) , Fp :: Normal ) ) ;
513
+ assert!( matches!( Float :: SUBNORMAL . classify( ) , Fp :: Subnormal ) ) ;
514
+ }
515
+ }
516
+
495
517
float_test ! {
496
518
name: min,
497
519
attrs: {
You can’t perform that action at this time.
0 commit comments