move test

This commit is contained in:
Aleksey Kladov 2021-10-10 11:29:26 +03:00
parent 408475a593
commit 7e53a3ce23
3 changed files with 21 additions and 19 deletions

View File

@ -130,6 +130,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
(T![&&], _) | (_, T![&&]) => " ",
(T![,], _) => " ",
(T![fn], T!['(']) => "",
(T![']'], _) if curr_kind.is_keyword() => " ",
_ if prev_kind.is_keyword() => " ",
_ => "",
};

View File

@ -936,3 +936,23 @@ fn foo() {
"#]],
);
}
#[test]
fn test_meta() {
check(
r#"
macro_rules! m {
($m:meta) => ( #[$m] fn bar() {} )
}
m! { cfg(target_os = "windows") }
m! { hello::world }
"#,
expect![[r##"
macro_rules! m {
($m:meta) => ( #[$m] fn bar() {} )
}
#[cfg(target_os = "windows")] fn bar() {}
#[hello::world] fn bar() {}
"##]],
);
}

View File

@ -101,25 +101,6 @@ fn test_attr_to_token_tree() {
);
}
#[test]
fn test_meta() {
parse_macro(
r#"
macro_rules! foo {
($ i:meta) => (
#[$ i]
fn bar() {}
)
}
"#,
)
.assert_expand_items(
r#"foo! { cfg(target_os = "windows") }"#,
r#"# [cfg (target_os = "windows")] fn bar () {}"#,
)
.assert_expand_items(r#"foo! { hello::world }"#, r#"# [hello :: world] fn bar () {}"#);
}
#[test]
fn test_meta_doc_comments() {
parse_macro(