@@ -103,18 +103,26 @@ fn test_const_deallocate_at_runtime() {
103103#[ cfg( not( bootstrap) ) ]
104104#[ test]
105105fn test_three_way_compare_in_const_contexts ( ) {
106- use core:: cmp:: Ordering :: * ;
106+ use core:: cmp:: Ordering :: { self , * } ;
107107 use core:: intrinsics:: three_way_compare;
108108
109- const {
110- assert ! ( Less as i8 == three_way_compare( 123_u16 , 456 ) as _) ;
111- assert ! ( Equal as i8 == three_way_compare( 456_u16 , 456 ) as _) ;
112- assert ! ( Greater as i8 == three_way_compare( 789_u16 , 456 ) as _) ;
113- assert ! ( Less as i8 == three_way_compare( 'A' , 'B' ) as _) ;
114- assert ! ( Equal as i8 == three_way_compare( 'B' , 'B' ) as _) ;
115- assert ! ( Greater as i8 == three_way_compare( 'C' , 'B' ) as _) ;
116- assert ! ( Less as i8 == three_way_compare( -123_i16 , 456 ) as _) ;
117- assert ! ( Equal as i8 == three_way_compare( 456_i16 , 456 ) as _) ;
118- assert ! ( Greater as i8 == three_way_compare( 123_i16 , -456 ) as _) ;
119- }
109+ const UNSIGNED_LESS : Ordering = three_way_compare ( 123_u16 , 456 ) ;
110+ const UNSIGNED_EQUAL : Ordering = three_way_compare ( 456_u16 , 456 ) ;
111+ const UNSIGNED_GREATER : Ordering = three_way_compare ( 789_u16 , 456 ) ;
112+ const CHAR_LESS : Ordering = three_way_compare ( 'A' , 'B' ) ;
113+ const CHAR_EQUAL : Ordering = three_way_compare ( 'B' , 'B' ) ;
114+ const CHAR_GREATER : Ordering = three_way_compare ( 'C' , 'B' ) ;
115+ const SIGNED_LESS : Ordering = three_way_compare ( 123_i64 , 456 ) ;
116+ const SIGNED_EQUAL : Ordering = three_way_compare ( 456_i64 , 456 ) ;
117+ const SIGNED_GREATER : Ordering = three_way_compare ( 789_i64 , 456 ) ;
118+
119+ assert_eq ! ( UNSIGNED_LESS , Less ) ;
120+ assert_eq ! ( UNSIGNED_EQUAL , Equal ) ;
121+ assert_eq ! ( UNSIGNED_GREATER , Greater ) ;
122+ assert_eq ! ( CHAR_LESS , Less ) ;
123+ assert_eq ! ( CHAR_EQUAL , Equal ) ;
124+ assert_eq ! ( CHAR_GREATER , Greater ) ;
125+ assert_eq ! ( SIGNED_LESS , Less ) ;
126+ assert_eq ! ( SIGNED_EQUAL , Equal ) ;
127+ assert_eq ! ( SIGNED_GREATER , Greater ) ;
120128}
0 commit comments