diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-10-09 16:22:42 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-10-09 16:22:42 +0300 |
| commit | 574df660e480360764d40d5174c510302500162c (patch) | |
| tree | 5b8423d556b2398b0c8555fa6da625da35801897 | |
| parent | b21244e080f0abc489be0f75c5047e6671b588d7 (diff) | |
| download | rust-574df660e480360764d40d5174c510302500162c.tar.gz rust-574df660e480360764d40d5174c510302500162c.zip | |
move test
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests.rs | 1 | ||||
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe.rs | 26 | ||||
| -rw-r--r-- | crates/mbe/src/tests/expand.rs | 22 |
3 files changed, 27 insertions, 22 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs index 83765bfb513..a899b2c1f38 100644 --- a/crates/hir_def/src/macro_expansion_tests.rs +++ b/crates/hir_def/src/macro_expansion_tests.rs @@ -102,6 +102,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String { let space = match (prev_kind, curr_kind) { _ if prev_kind.is_trivia() || curr_kind.is_trivia() => "", (T![=], _) | (_, T![=]) => " ", + (_, T!['{']) => " ", (T![;], _) => "\n", (IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ", (IDENT, _) if curr_kind.is_keyword() => " ", diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index cc6551f8aa6..1e3d554b83a 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -46,3 +46,29 @@ macro_rules! m { "#]], ); } + +#[test] +fn tries_all_branches_matching_token_literally() { + check( + r#" +macro_rules! m { + ($ i:ident) => ( mod $ i {} ); + (= $ i:ident) => ( fn $ i() {} ); + (+ $ i:ident) => ( struct $ i; ) +} +m! { foo } +m! { = bar } +m! { + Baz } +"#, + expect![[r#" +macro_rules! m { + ($ i:ident) => ( mod $ i {} ); + (= $ i:ident) => ( fn $ i() {} ); + (+ $ i:ident) => ( struct $ i; ) +} +mod foo {} +fn bar() {} +struct Baz; +"#]], + ) +} diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index 360d24db570..48143f0a60b 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs @@ -210,28 +210,6 @@ fn test_expr_order() { } #[test] -fn test_fail_match_pattern_by_first_token() { - parse_macro( - r#" - macro_rules! foo { - ($ i:ident) => ( - mod $ i {} - ); - (= $ i:ident) => ( - fn $ i() {} - ); - (+ $ i:ident) => ( - struct $ i; - ) - } -"#, - ) - .assert_expand_items("foo! { foo }", "mod foo {}") - .assert_expand_items("foo! { = bar }", "fn bar () {}") - .assert_expand_items("foo! { + Baz }", "struct Baz ;"); -} - -#[test] fn test_fail_match_pattern_by_last_token() { parse_macro( r#" |
