aboutsummaryrefslogtreecommitdiff
path: root/tests/test.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-04-10 15:57:36 -0700
committerDavid Tolnay <dtolnay@gmail.com>2019-04-10 15:57:36 -0700
commit5a2f730055113da243475b24752540ce61abccd3 (patch)
tree4de7c2d7b04bc380fb01c5ef2fd2a46c7f1f0290 /tests/test.rs
parent35d24c390b6e3cd1cff5f2b4e1b50a91004ee76c (diff)
downloadproc-macro2-5a2f730055113da243475b24752540ce61abccd3.tar.gz
Add trailing commas in test_debug_tokenstream
Diffstat (limited to 'tests/test.rs')
-rw-r--r--tests/test.rs53
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/test.rs b/tests/test.rs
index 055ebfd..426313a 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -339,6 +339,27 @@ TokenStream [
delimiter: Bracket,
stream: TokenStream [
Ident {
+ sym: a,
+ },
+ Punct {
+ op: '+',
+ spacing: Alone,
+ },
+ Literal {
+ lit: 1,
+ },
+ ],
+ },
+]\
+ ";
+
+ #[cfg(not(procmacro2_semver_exempt))]
+ let expected_before_trailing_commas = "\
+TokenStream [
+ Group {
+ delimiter: Bracket,
+ stream: TokenStream [
+ Ident {
sym: a
},
Punct {
@@ -361,6 +382,31 @@ TokenStream [
stream: TokenStream [
Ident {
sym: a,
+ span: bytes(2..3),
+ },
+ Punct {
+ op: '+',
+ spacing: Alone,
+ span: bytes(4..5),
+ },
+ Literal {
+ lit: 1,
+ span: bytes(6..7),
+ },
+ ],
+ span: bytes(1..8),
+ },
+]\
+ ";
+
+ #[cfg(procmacro2_semver_exempt)]
+ let expected_before_trailing_commas = "\
+TokenStream [
+ Group {
+ delimiter: Bracket,
+ stream: TokenStream [
+ Ident {
+ sym: a,
span: bytes(2..3)
},
Punct {
@@ -378,7 +424,12 @@ TokenStream [
]\
";
- assert_eq!(expected, format!("{:#?}", tts));
+ let actual = format!("{:#?}", tts);
+ if actual.ends_with(",\n]") {
+ assert_eq!(expected, actual);
+ } else {
+ assert_eq!(expected_before_trailing_commas, actual);
+ }
}
#[test]