mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
move some tests
This commit is contained in:
parent
cb1b6a273f
commit
036c0ff8c7
@ -102,9 +102,11 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
|
|||||||
let curr_kind = token.kind();
|
let curr_kind = token.kind();
|
||||||
let space = match (prev_kind, curr_kind) {
|
let space = match (prev_kind, curr_kind) {
|
||||||
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
|
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
|
||||||
|
(T!['{'], T!['}']) => "",
|
||||||
(T![=], _) | (_, T![=]) => " ",
|
(T![=], _) | (_, T![=]) => " ",
|
||||||
(_, T!['{']) => " ",
|
(_, T!['{']) => " ",
|
||||||
(T![;] | T!['}'], _) => "\n",
|
(T![;] | T!['{'] | T!['}'], _) => "\n",
|
||||||
|
(_, T!['}']) => "\n",
|
||||||
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
|
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
|
||||||
(IDENT, _) if curr_kind.is_keyword() => " ",
|
(IDENT, _) if curr_kind.is_keyword() => " ",
|
||||||
(_, IDENT) if prev_kind.is_keyword() => " ",
|
(_, IDENT) if prev_kind.is_keyword() => " ",
|
||||||
|
@ -159,3 +159,66 @@ struct Bar;
|
|||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_match_group_pattern_with_multiple_defs() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( impl Bar { $ ( fn $ i {} )*} );
|
||||||
|
}
|
||||||
|
m! { foo, bar }
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( impl Bar { $ ( fn $ i {} )*} );
|
||||||
|
}
|
||||||
|
impl Bar {
|
||||||
|
fn foo {}
|
||||||
|
fn bar {}
|
||||||
|
}
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_match_group_pattern_with_multiple_statement() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( fn baz { $ ( $ i (); )*} );
|
||||||
|
}
|
||||||
|
m! { foo, bar }
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( fn baz { $ ( $ i (); )*} );
|
||||||
|
}
|
||||||
|
fn baz {
|
||||||
|
foo();
|
||||||
|
bar();
|
||||||
|
}
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_match_group_pattern_with_multiple_statement_without_semi() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( fn baz { $ ( $i() );*} );
|
||||||
|
}
|
||||||
|
m! { foo, bar }
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($ ($ i:ident),*) => ( fn baz { $ ( $i() );*} );
|
||||||
|
}
|
||||||
|
fn baz {
|
||||||
|
foo();
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -209,48 +209,6 @@ fn test_expr_order() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_match_group_pattern_with_multiple_defs() {
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($ ($ i:ident),*) => ( struct Bar { $ (
|
|
||||||
fn $ i {}
|
|
||||||
)*} );
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand_items("foo! { foo, bar }", "struct Bar {fn foo {} fn bar {}}");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_match_group_pattern_with_multiple_statement() {
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($ ($ i:ident),*) => ( fn baz { $ (
|
|
||||||
$ i ();
|
|
||||||
)*} );
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand_items("foo! { foo, bar }", "fn baz {foo () ; bar () ;}");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_match_group_pattern_with_multiple_statement_without_semi() {
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($ ($ i:ident),*) => ( fn baz { $ (
|
|
||||||
$i()
|
|
||||||
);*} );
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand_items("foo! { foo, bar }", "fn baz {foo () ;bar ()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_match_group_empty_fixed_token() {
|
fn test_match_group_empty_fixed_token() {
|
||||||
parse_macro(
|
parse_macro(
|
||||||
|
Loading…
Reference in New Issue
Block a user