diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-01 08:35:13 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-08 14:39:59 +1100 |
| commit | 438b9a6e82cd74102bd41636dc48b6b846101a59 (patch) | |
| tree | 1c5dc5727966b00d4d1cb53b2ee94f606095206a /tests/ui/macros/stringify.rs | |
| parent | 783d4b8b2629c31ff8359ce744060afdcb0a5bea (diff) | |
| download | rust-438b9a6e82cd74102bd41636dc48b6b846101a59.tar.gz rust-438b9a6e82cd74102bd41636dc48b6b846101a59.zip | |
More tests for token stream pretty-printing with adjacent punctuation.
We currently do the wrong thing on a lot of these. The next commit will fix things.
Diffstat (limited to 'tests/ui/macros/stringify.rs')
| -rw-r--r-- | tests/ui/macros/stringify.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 31e0d30c78b..70ca00285c4 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -801,3 +801,32 @@ fn test_vis() { assert_eq!(inherited_vis!(struct), ""); assert_eq!(stringify!(), ""); } + +macro_rules! p { + ([$($tt:tt)*], $s:literal) => { + assert_eq!(stringify!($($tt)*), $s); + }; +} + +#[test] +fn test_punct() { + // For all these cases, we must preserve spaces between the tokens. + // Otherwise, any old proc macro that parses pretty-printed code might glue + // together tokens that shouldn't be glued. + p!([ = = < < <= <= == == != != >= >= > > ], "= = < < <= <= == == != != >= >= > >"); + p!([ && && & & || || | | ! ! ], "&& && & & || || | |!!"); // FIXME + p!([ ~ ~ @ @ # # ], "~ ~ @ @ # #"); + p!([ . . .. .. ... ... ..= ..=], ".... .. ... ... ..= ..="); // FIXME + p!([ , , ; ; : : :: :: ], ",, ; ; : : :: ::"); // FIXME + p!([ -> -> <- <- => =>], "-> -> <- <- => =>"); + p!([ $ $ ? ? ' ' ], "$$? ? ' '"); // FIXME + p!([ + + += += - - -= -= * * *= *= / / /= /= ], "+ + += += - - -= -= * * *= *= / / /= /="); + p!([ % % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>= ], + "% % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>="); + + // For these one we must insert spaces between adjacent tokens, again due + // to proc macros. + p!([ +! ?= |> >>@ --> <-- $$ =====> ], "+! ? = | > >> @ - -> <- - $$== == =>"); // FIXME + p!([ ,; ;, ** @@ $+$ >< <> ?? +== ], ", ; ;, * * @ @ $+ $> < < > ? ? += ="); // FIXME + p!([ :#!@|$=&*,+;*~? ], ": #! @ | $= & *, + ; * ~ ?"); // FIXME +} |
