@@ -713,20 +713,6 @@ float_test! {
713
713
}
714
714
}
715
715
716
- float_test ! {
717
- name: abs,
718
- attrs: {
719
- f16: #[ cfg( any( miri, target_has_reliable_f16_math) ) ] ,
720
- f128: #[ cfg( any( miri, target_has_reliable_f128_math) ) ] ,
721
- } ,
722
- test<Float > {
723
- assert_biteq!( ( -1.0 as Float ) . abs( ) , 1.0 ) ;
724
- assert_biteq!( ( 1.0 as Float ) . abs( ) , 1.0 ) ;
725
- assert_biteq!( Float :: NEG_INFINITY . abs( ) , Float :: INFINITY ) ;
726
- assert_biteq!( Float :: INFINITY . abs( ) , Float :: INFINITY ) ;
727
- }
728
- }
729
-
730
716
float_test ! {
731
717
name: copysign,
732
718
attrs: {
@@ -951,3 +937,23 @@ float_test! {
951
937
assert!( Float :: NEG_INFINITY . fract( ) . is_nan( ) ) ;
952
938
}
953
939
}
940
+
941
+ float_test ! {
942
+ name: abs,
943
+ attrs: {
944
+ f16: #[ cfg( any( miri, target_has_reliable_f16_math) ) ] ,
945
+ f128: #[ cfg( any( miri, target_has_reliable_f128_math) ) ] ,
946
+ } ,
947
+ test<Float > {
948
+ let one: Float = 1.0 ;
949
+ let zero: Float = 0.0 ;
950
+ assert_biteq!( Float :: INFINITY . abs( ) , Float :: INFINITY ) ;
951
+ assert_biteq!( one. abs( ) , one) ;
952
+ assert_biteq!( zero. abs( ) , zero) ;
953
+ assert_biteq!( ( -zero) . abs( ) , zero) ;
954
+ assert_biteq!( ( -one) . abs( ) , one) ;
955
+ assert_biteq!( Float :: NEG_INFINITY . abs( ) , Float :: INFINITY ) ;
956
+ assert_biteq!( ( one / Float :: NEG_INFINITY ) . abs( ) , zero) ;
957
+ assert!( Float :: NAN . abs( ) . is_nan( ) ) ;
958
+ }
959
+ }
0 commit comments