internal: move test

This commit is contained in:
Aleksey Kladov 2021-10-09 16:31:26 +03:00
parent 59c86ff300
commit 959da8caa1
3 changed files with 36 additions and 24 deletions

View file

@ -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() => " ",

View file

@ -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;
"##]],
);
}

View file

@ -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(