@@ -7,7 +7,7 @@ extern crate ordered_float;
7
7
pub use num_traits:: float:: FloatCore as Float ;
8
8
#[ cfg( feature = "std" ) ]
9
9
pub use num_traits:: Float ;
10
- pub use num_traits:: { Bounded , FromPrimitive , Num , One , Signed , ToPrimitive , Zero } ;
10
+ pub use num_traits:: { Bounded , FloatConst , FromPrimitive , Num , One , Signed , ToPrimitive , Zero } ;
11
11
pub use ordered_float:: * ;
12
12
13
13
pub use std:: cmp:: Ordering :: * ;
@@ -693,6 +693,41 @@ fn from_ref() {
693
693
assert_eq ! ( f, 2.0f64 ) ;
694
694
}
695
695
696
+ macro_rules! test_float_const_method {
697
+ ( $type: ident < $inner: ident >, $method: ident) => {
698
+ assert_eq!( $type:: <$inner>:: $method( ) . into_inner( ) , $inner:: $method( ) )
699
+ } ;
700
+ }
701
+
702
+ macro_rules! test_float_const_methods {
703
+ ( $type: ident < $inner: ident >) => {
704
+ test_float_const_method!( $type<$inner>, E ) ;
705
+ test_float_const_method!( $type<$inner>, FRAC_1_PI ) ;
706
+ test_float_const_method!( $type<$inner>, FRAC_1_SQRT_2 ) ;
707
+ test_float_const_method!( $type<$inner>, FRAC_2_PI ) ;
708
+ test_float_const_method!( $type<$inner>, FRAC_2_SQRT_PI ) ;
709
+ test_float_const_method!( $type<$inner>, FRAC_PI_2 ) ;
710
+ test_float_const_method!( $type<$inner>, FRAC_PI_3 ) ;
711
+ test_float_const_method!( $type<$inner>, FRAC_PI_4 ) ;
712
+ test_float_const_method!( $type<$inner>, FRAC_PI_6 ) ;
713
+ test_float_const_method!( $type<$inner>, FRAC_PI_8 ) ;
714
+ test_float_const_method!( $type<$inner>, LN_10 ) ;
715
+ test_float_const_method!( $type<$inner>, LN_2 ) ;
716
+ test_float_const_method!( $type<$inner>, LOG10_E ) ;
717
+ test_float_const_method!( $type<$inner>, LOG2_E ) ;
718
+ test_float_const_method!( $type<$inner>, PI ) ;
719
+ test_float_const_method!( $type<$inner>, SQRT_2 ) ;
720
+ } ;
721
+ }
722
+
723
+ #[ test]
724
+ fn float_consts_equal_inner ( ) {
725
+ test_float_const_methods ! ( OrderedFloat <f64 >) ;
726
+ test_float_const_methods ! ( OrderedFloat <f32 >) ;
727
+ test_float_const_methods ! ( NotNan <f64 >) ;
728
+ test_float_const_methods ! ( NotNan <f32 >) ;
729
+ }
730
+
696
731
#[ cfg( feature = "arbitrary" ) ]
697
732
mod arbitrary_test {
698
733
use super :: { NotNan , OrderedFloat } ;
0 commit comments