Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/tests.rs')
-rw-r--r--crates/mbe/src/tests.rs146
1 files changed, 146 insertions, 0 deletions
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index 5422c9ae64..f6f12a9f9a 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -177,3 +177,149 @@ fn main() {
}"#]],
);
}
+
+#[test]
+fn expr_2021() {
+ check(
+ Edition::Edition2024,
+ Edition::Edition2024,
+ r#"
+($($e:expr),* $(,)?) => {
+ $($e);* ;
+};
+"#,
+ r#"
+ _,
+ const { 1 },
+"#,
+ expect![[r#"
+ IDENT _ 1:[email protected]#0
+ PUNCH ; [joint] 0:[email protected]#0
+ IDENT const 1:[email protected]#0
+ LITERAL Integer 1 1:[email protected]#0
+ PUNCH ; [alone] 0:[email protected]#0
+
+ _;
+ (const {
+ 1
+ });"#]],
+ );
+ check(
+ Edition::Edition2021,
+ Edition::Edition2024,
+ r#"
+($($e:expr),* $(,)?) => {
+ $($e);* ;
+};
+"#,
+ r#"
+ _,
+"#,
+ expect![[r#"
+ ExpandError {
+ inner: (
+ NoMatchingRule,
+ ),
+ }
+
+ PUNCH ; [alone] 0:[email protected]#0
+
+ ;"#]],
+ );
+ check(
+ Edition::Edition2021,
+ Edition::Edition2024,
+ r#"
+($($e:expr),* $(,)?) => {
+ $($e);* ;
+};
+"#,
+ r#"
+ const { 1 },
+"#,
+ expect![[r#"
+ ExpandError {
+ inner: (
+ NoMatchingRule,
+ ),
+ }
+
+ PUNCH ; [alone] 0:[email protected]#0
+
+ ;"#]],
+ );
+ check(
+ Edition::Edition2024,
+ Edition::Edition2024,
+ r#"
+($($e:expr_2021),* $(,)?) => {
+ $($e);* ;
+};
+"#,
+ r#"
+ 4,
+ "literal",
+ funcall(),
+ future.await,
+ break 'foo bar,
+"#,
+ expect![[r#"
+ LITERAL Integer 4 1:[email protected]#0
+ PUNCH ; [joint] 0:[email protected]#0
+ LITERAL Str literal 1:[email protected]#0
+ PUNCH ; [joint] 0:[email protected]#0
+ IDENT funcall 1:[email protected]#0
+ PUNCH ; [joint] 0:[email protected]#0
+ IDENT future 1:[email protected]#0
+ PUNCH . [alone] 1:[email protected]#0
+ IDENT await 1:[email protected]#0
+ PUNCH ; [joint] 0:[email protected]#0
+ IDENT break 1:[email protected]#0
+ PUNCH ' [joint] 1:[email protected]#0
+ IDENT foo 1:[email protected]#0
+ IDENT bar 1:[email protected]#0
+ PUNCH ; [alone] 0:[email protected]#0
+
+ 4;
+ "literal";
+ (funcall());
+ (future.await);
+ (break 'foo bar);"#]],
+ );
+ check(
+ Edition::Edition2024,
+ Edition::Edition2024,
+ r#"
+($($e:expr_2021),* $(,)?) => {
+ $($e);* ;
+};
+"#,
+ r#"
+ _,
+"#,
+ expect![[r#"
+ ExpandError {
+ inner: (
+ NoMatchingRule,
+ ),
+ }
+
+ PUNCH ; [alone] 0:[email protected]#0
+
+ ;"#]],
+ );
+}