From 7de4b964a9ac25b95ec303f675b36d8c04859e34 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Jan 2022 16:48:10 +0300 Subject: [PATCH] add test for macro items --- crates/parser/src/tests/top_entries.rs | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/crates/parser/src/tests/top_entries.rs b/crates/parser/src/tests/top_entries.rs index 0b77c0a5b9..2d867a4df3 100644 --- a/crates/parser/src/tests/top_entries.rs +++ b/crates/parser/src/tests/top_entries.rs @@ -92,6 +92,43 @@ fn macro_stmt() { ); } +#[test] +fn macro_items() { + check( + TopEntryPoint::MacroItems, + "#!/usr/bin/rust", + expect![[r##" + MACRO_ITEMS + ERROR + SHEBANG "#!/usr/bin/rust" + error 0: expected an item + "##]], + ); + check( + TopEntryPoint::MacroItems, + "struct S; foo!{}", + expect![[r#" + MACRO_ITEMS + STRUCT + STRUCT_KW "struct" + WHITESPACE " " + NAME + IDENT "S" + SEMICOLON ";" + WHITESPACE " " + MACRO_CALL + PATH + PATH_SEGMENT + NAME_REF + IDENT "foo" + BANG "!" + TOKEN_TREE + L_CURLY "{" + R_CURLY "}" + "#]], + ); +} + #[track_caller] fn check(entry: TopEntryPoint, input: &str, expect: expect_test::Expect) { let (parsed, _errors) = super::parse(entry, input);