From 2bd7c747066fc5d1e8537b81a1156ff4e5e40ae6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Jan 2022 15:17:32 +0300 Subject: [PATCH] add tests for macro statements --- crates/parser/src/tests/entries.rs | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/crates/parser/src/tests/entries.rs b/crates/parser/src/tests/entries.rs index ea8ff41502..c52f15418f 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);