@@ -1050,6 +1050,11 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
1050
1050
mod tests {
1051
1051
use std:: prelude:: v1:: * ;
1052
1052
1053
+ macro_rules! t {
1054
+ ( $a: expr, $b: expr) => { {
1055
+ assert_eq!( format!( "{}" , :: demangle( $a) ) , $b) ;
1056
+ } } ;
1057
+ }
1053
1058
macro_rules! t_nohash {
1054
1059
( $a: expr, $b: expr) => { {
1055
1060
assert_eq!( format!( "{:#}" , :: demangle( $a) ) , $b) ;
@@ -1060,6 +1065,23 @@ mod tests {
1060
1065
t_nohash!( concat!( "_RMC0" , $a) , concat!( "<" , $b, ">" ) )
1061
1066
} ;
1062
1067
}
1068
+ macro_rules! t_const {
1069
+ ( $mangled: expr, $value: expr) => {
1070
+ t_nohash!(
1071
+ concat!( "_RIC0K" , $mangled, "E" ) ,
1072
+ concat!( "::<" , $value, ">" )
1073
+ )
1074
+ } ;
1075
+ }
1076
+ macro_rules! t_const_typed {
1077
+ ( $mangled: expr, $value: expr, $value_ty: expr) => { {
1078
+ t_const!( $mangled, $value) ;
1079
+ t!(
1080
+ concat!( "_RIC0K" , $mangled, "E" ) ,
1081
+ concat!( "[0]::<" , $value, ": " , $value_ty, ">" )
1082
+ ) ;
1083
+ } } ;
1084
+ }
1063
1085
1064
1086
#[ test]
1065
1087
fn demangle_crate_with_leading_digit ( ) {
@@ -1102,46 +1124,20 @@ mod tests {
1102
1124
"INtC8arrayvec8ArrayVechKj7b_E" ,
1103
1125
"arrayvec::ArrayVec<u8, 123>"
1104
1126
) ;
1127
+ t_const_typed ! ( "j7b_" , "123" , "usize" ) ;
1105
1128
}
1106
1129
1107
1130
#[ test]
1108
1131
fn demangle_min_const_generics ( ) {
1109
- t_nohash ! (
1110
- "_RMCs4fqI2P2rA04_13const_genericINtB0_8UnsignedKhb_E" ,
1111
- "<const_generic::Unsigned<11>>"
1112
- ) ;
1113
- t_nohash ! (
1114
- "_RMCs4fqI2P2rA04_13const_genericINtB0_6SignedKs98_E" ,
1115
- "<const_generic::Signed<152>>"
1116
- ) ;
1117
- t_nohash ! (
1118
- "_RMCs4fqI2P2rA04_13const_genericINtB0_6SignedKanb_E" ,
1119
- "<const_generic::Signed<-11>>"
1120
- ) ;
1121
- t_nohash ! (
1122
- "_RMCs4fqI2P2rA04_13const_genericINtB0_4BoolKb0_E" ,
1123
- "<const_generic::Bool<false>>"
1124
- ) ;
1125
- t_nohash ! (
1126
- "_RMCs4fqI2P2rA04_13const_genericINtB0_4BoolKb1_E" ,
1127
- "<const_generic::Bool<true>>"
1128
- ) ;
1129
- t_nohash ! (
1130
- "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc76_E" ,
1131
- "<const_generic::Char<'v'>>"
1132
- ) ;
1133
- t_nohash ! (
1134
- "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKca_E" ,
1135
- "<const_generic::Char<'\\ n'>>"
1136
- ) ;
1137
- t_nohash ! (
1138
- "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E" ,
1139
- "<const_generic::Char<'∂'>>"
1140
- ) ;
1141
- t_nohash ! (
1142
- "_RNvNvMCs4fqI2P2rA04_13const_genericINtB4_3FooKpE3foo3FOO" ,
1143
- "<const_generic::Foo<_>>::foo::FOO"
1144
- ) ;
1132
+ t_const ! ( "p" , "_" ) ;
1133
+ t_const_typed ! ( "hb_" , "11" , "u8" ) ;
1134
+ t_const_typed ! ( "s98_" , "152" , "i16" ) ;
1135
+ t_const_typed ! ( "anb_" , "-11" , "i8" ) ;
1136
+ t_const_typed ! ( "b0_" , "false" , "bool" ) ;
1137
+ t_const_typed ! ( "b1_" , "true" , "bool" ) ;
1138
+ t_const_typed ! ( "c76_" , "'v'" , "char" ) ;
1139
+ t_const_typed ! ( "ca_" , "'\\ n'" , "char" ) ;
1140
+ t_const_typed ! ( "c2202_" , "'∂'" , "char" ) ;
1145
1141
}
1146
1142
1147
1143
#[ test]
0 commit comments