From 1abe3f8275d1921c0f025edddd8bf7ad57faa333 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 9 Oct 2021 14:22:49 +0300 Subject: [PATCH] internal: move tests --- crates/hir_def/src/macro_expansion_tests.rs | 20 ++++++++++++++++++++ crates/mbe/src/syntax_bridge.rs | 8 -------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs index c00795d34b1..8fa1f307f15 100644 --- a/crates/hir_def/src/macro_expansion_tests.rs +++ b/crates/hir_def/src/macro_expansion_tests.rs @@ -151,3 +151,23 @@ macro_rules! m { "#]], ) } + +#[test] +fn broken_parenthesis_sequence() { + check( + r#" +macro_rules! m1 { ($x:ident) => { ($x } } +macro_rules! m2 { ($x:ident) => {} } + +m1!(); +m2!(x +"#, + expect![[r#" +macro_rules! m1 { ($x:ident) => { ($x } } +macro_rules! m2 { ($x:ident) => {} } + +/* error: Failed to find macro definition */ +/* error: Failed to lower macro args to token tree */ + "#]], + ) +} diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index 037881cef6e..b6099b724da 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs @@ -821,12 +821,4 @@ fn test_token_tree_last_child_is_white_space() { let tt = syntax_node_to_token_tree(token_tree.syntax()).0; assert_eq!(tt.delimiter_kind(), Some(tt::DelimiterKind::Brace)); } - - #[test] - fn test_missing_closing_delim() { - let source_file = ast::SourceFile::parse("m!(x").tree(); - let node = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); - let tt = syntax_node_to_token_tree(node.syntax()).0.to_string(); - assert_eq_text!(&*tt, "( x"); - } }