about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2022-01-02 15:17:32 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2022-01-02 15:17:32 +0300
commit2bd7c747066fc5d1e8537b81a1156ff4e5e40ae6 (patch)
tree1cfe0fb593461eb609c08cc92fd071c6ac088aec
parentf2ea7853ee9b2b44464b93a6008ce8e1e39e2127 (diff)
downloadrust-2bd7c747066fc5d1e8537b81a1156ff4e5e40ae6.tar.gz
rust-2bd7c747066fc5d1e8537b81a1156ff4e5e40ae6.zip
add tests for macro statements
-rw-r--r--crates/parser/src/tests/entries.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/parser/src/tests/entries.rs b/crates/parser/src/tests/entries.rs
index ea8ff415029..c52f15418f3 100644
--- a/crates/parser/src/tests/entries.rs
+++ b/crates/parser/src/tests/entries.rs
@@ -159,6 +159,49 @@ fn source_file() {
     );
 }
 
+#[test]
+fn macro_stmt() {
+    check_top(
+        TopEntryPoint::MacroStmts,
+        "#!/usr/bin/rust",
+        expect![[r##"
+            MACRO_STMTS
+              ERROR
+                SHEBANG "#!/usr/bin/rust"
+            error 0: expected expression
+        "##]],
+    );
+    check_top(
+        TopEntryPoint::MacroStmts,
+        "let x = 1 2 struct S;",
+        expect![[r#"
+            MACRO_STMTS
+              LET_STMT
+                LET_KW "let"
+                WHITESPACE " "
+                IDENT_PAT
+                  NAME
+                    IDENT "x"
+                WHITESPACE " "
+                EQ "="
+                WHITESPACE " "
+                LITERAL
+                  INT_NUMBER "1"
+              WHITESPACE " "
+              EXPR_STMT
+                LITERAL
+                  INT_NUMBER "2"
+              WHITESPACE " "
+              STRUCT
+                STRUCT_KW "struct"
+                WHITESPACE " "
+                NAME
+                  IDENT "S"
+                SEMICOLON ";"
+        "#]],
+    );
+}
+
 #[track_caller]
 fn check_top(entry: TopEntryPoint, input: &str, expect: expect_test::Expect) {
     let (parsed, _errors) = super::parse(entry, input);