@@ -801,3 +801,32 @@ fn test_vis() {
801
801
assert_eq ! ( inherited_vis!( struct ) , "" ) ;
802
802
assert_eq ! ( stringify!( ) , "" ) ;
803
803
}
804
+
805
+ macro_rules! p {
806
+ ( [ $( $tt: tt) * ] , $s: literal) => {
807
+ assert_eq!( stringify!( $( $tt) * ) , $s) ;
808
+ } ;
809
+ }
810
+
811
+ #[ test]
812
+ fn test_punct ( ) {
813
+ // For all these cases, we must preserve spaces between the tokens.
814
+ // Otherwise, any old proc macro that parses pretty-printed code might glue
815
+ // together tokens that shouldn't be glued.
816
+ p ! ( [ = = < < <= <= == == != != >= >= > > ] , "= = < < <= <= == == != != >= >= > >" ) ;
817
+ p ! ( [ && && & & || || | | ! ! ] , "&& && & & || || | |!!" ) ; // FIXME
818
+ p ! ( [ ~ ~ @ @ # # ] , "~ ~ @ @ # #" ) ;
819
+ p ! ( [ . . .. .. ... ... ..= ..=] , ".... .. ... ... ..= ..=" ) ; // FIXME
820
+ p ! ( [ , , ; ; : : :: :: ] , ",, ; ; : : :: ::" ) ; // FIXME
821
+ p ! ( [ -> -> <- <- => =>] , "-> -> <- <- => =>" ) ;
822
+ p ! ( [ $ $ ? ? ' ' ] , "$$? ? ' '" ) ; // FIXME
823
+ p ! ( [ + + += += - - -= -= * * *= *= / / /= /= ] , "+ + += += - - -= -= * * *= *= / / /= /=" ) ;
824
+ p ! ( [ % % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>= ] ,
825
+ "% % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>=" ) ;
826
+
827
+ // For these one we must insert spaces between adjacent tokens, again due
828
+ // to proc macros.
829
+ p ! ( [ +! ?= |> >>@ --> <-- $$ =====> ] , "+! ? = | > >> @ - -> <- - $$== == =>" ) ; // FIXME
830
+ p ! ( [ , ; ; , * * @@ $+$ >< <> ?? +== ] , ", ; ;, * * @ @ $+ $> < < > ? ? += =" ) ; // FIXME
831
+ p ! ( [ : #!@|$=& * , +; * ~? ] , ": #! @ | $= & *, + ; * ~ ?" ) ; // FIXME
832
+ }
0 commit comments