Skip to content

Commit 2bd7c74

Browse files
committed
add tests for macro statements
1 parent f2ea785 commit 2bd7c74

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

crates/parser/src/tests/entries.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,49 @@ fn source_file() {
159159
);
160160
}
161161

162+
#[test]
163+
fn macro_stmt() {
164+
check_top(
165+
TopEntryPoint::MacroStmts,
166+
"#!/usr/bin/rust",
167+
expect![[r##"
168+
MACRO_STMTS
169+
ERROR
170+
SHEBANG "#!/usr/bin/rust"
171+
error 0: expected expression
172+
"##]],
173+
);
174+
check_top(
175+
TopEntryPoint::MacroStmts,
176+
"let x = 1 2 struct S;",
177+
expect![[r#"
178+
MACRO_STMTS
179+
LET_STMT
180+
LET_KW "let"
181+
WHITESPACE " "
182+
IDENT_PAT
183+
NAME
184+
IDENT "x"
185+
WHITESPACE " "
186+
EQ "="
187+
WHITESPACE " "
188+
LITERAL
189+
INT_NUMBER "1"
190+
WHITESPACE " "
191+
EXPR_STMT
192+
LITERAL
193+
INT_NUMBER "2"
194+
WHITESPACE " "
195+
STRUCT
196+
STRUCT_KW "struct"
197+
WHITESPACE " "
198+
NAME
199+
IDENT "S"
200+
SEMICOLON ";"
201+
"#]],
202+
);
203+
}
204+
162205
#[track_caller]
163206
fn check_top(entry: TopEntryPoint, input: &str, expect: expect_test::Expect) {
164207
let (parsed, _errors) = super::parse(entry, input);

0 commit comments

Comments
 (0)