mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
internal: move test
This commit is contained in:
parent
59c86ff300
commit
959da8caa1
3 changed files with 36 additions and 24 deletions
|
@ -103,7 +103,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
|
|||
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
|
||||
(T![=], _) | (_, T![=]) => " ",
|
||||
(_, T!['{']) => " ",
|
||||
(T![;], _) => "\n",
|
||||
(T![;] | T!['}'], _) => "\n",
|
||||
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
|
||||
(IDENT, _) if curr_kind.is_keyword() => " ",
|
||||
(_, IDENT) if prev_kind.is_keyword() => " ",
|
||||
|
|
|
@ -124,3 +124,38 @@ struct Baz;
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_by_separator_token() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m {
|
||||
($ ($ i:ident),*) => ($ ( mod $ i {} )*);
|
||||
($ ($ i:ident)#*) => ($ ( fn $ i() {} )*);
|
||||
($ i:ident ,# $ j:ident) => ( struct $ i; struct $ j; )
|
||||
}
|
||||
|
||||
m! { foo, bar }
|
||||
|
||||
m! { foo# bar }
|
||||
|
||||
m! { Foo,# Bar }
|
||||
"#,
|
||||
expect![[r##"
|
||||
macro_rules! m {
|
||||
($ ($ i:ident),*) => ($ ( mod $ i {} )*);
|
||||
($ ($ i:ident)#*) => ($ ( fn $ i() {} )*);
|
||||
($ i:ident ,# $ j:ident) => ( struct $ i; struct $ j; )
|
||||
}
|
||||
|
||||
mod foo {}
|
||||
mod bar {}
|
||||
|
||||
fn foo() {}
|
||||
fn bar() {}
|
||||
|
||||
struct Foo;
|
||||
struct Bar;
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -209,29 +209,6 @@ fn test_expr_order() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_group_pattern_by_separator_token() {
|
||||
parse_macro(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($ ($ i:ident),*) => ($ (
|
||||
mod $ i {}
|
||||
)*);
|
||||
($ ($ i:ident)#*) => ($ (
|
||||
fn $ i() {}
|
||||
)*);
|
||||
($ i:ident ,# $ j:ident) => (
|
||||
struct $ i;
|
||||
struct $ j;
|
||||
)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.assert_expand_items("foo! { foo, bar }", "mod foo {} mod bar {}")
|
||||
.assert_expand_items("foo! { foo# bar }", "fn foo () {} fn bar () {}")
|
||||
.assert_expand_items("foo! { Foo,# Bar }", "struct Foo ; struct Bar ;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_group_pattern_with_multiple_defs() {
|
||||
parse_macro(
|
||||
|
|
Loading…
Reference in a new issue