move tests

This commit is contained in:
Aleksey Kladov 2021-10-10 11:39:08 +03:00
parent 7e53a3ce23
commit a3470a8114
4 changed files with 89 additions and 84 deletions

View file

@ -307,6 +307,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
}
fn convert_doc_comment(token: &syntax::SyntaxToken) -> Option<Vec<tt::TokenTree>> {
cov_mark::hit!(test_meta_doc_comments);
let comment = ast::Comment::cast(token.clone())?;
let doc = comment.kind().doc?;

View file

@ -101,90 +101,6 @@ fn test_attr_to_token_tree() {
);
}
#[test]
fn test_meta_doc_comments() {
parse_macro(
r#"
macro_rules! foo {
($(#[$ i:meta])+) => (
$(#[$ i])+
fn bar() {}
)
}
"#,
).
assert_expand_items(
r#"foo! {
/// Single Line Doc 1
/**
MultiLines Doc
*/
}"#,
"# [doc = \" Single Line Doc 1\"] # [doc = \"\\n MultiLines Doc\\n \"] fn bar () {}",
);
}
#[test]
fn test_meta_extended_key_value_attributes() {
parse_macro(
r#"
macro_rules! foo {
(#[$i:meta]) => (
#[$ i]
fn bar() {}
)
}
"#,
)
.assert_expand_items(
r#"foo! { #[doc = concat!("The `", "bla", "` lang item.")] }"#,
r#"# [doc = concat ! ("The `" , "bla" , "` lang item.")] fn bar () {}"#,
);
}
#[test]
fn test_meta_doc_comments_non_latin() {
parse_macro(
r#"
macro_rules! foo {
($(#[$ i:meta])+) => (
$(#[$ i])+
fn bar() {}
)
}
"#,
).
assert_expand_items(
r#"foo! {
/// 錦瑟無端五十弦,一弦一柱思華年。
/**
*/
}"#,
"# [doc = \" 錦瑟無端五十弦,一弦一柱思華年。\"] # [doc = \"\\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\\n \"] fn bar () {}",
);
}
#[test]
fn test_meta_doc_comments_escaped_characters() {
parse_macro(
r#"
macro_rules! foo {
($(#[$ i:meta])+) => (
$(#[$ i])+
fn bar() {}
)
}
"#,
)
.assert_expand_items(
r#"foo! {
/// \ " '
}"#,
r#"# [doc = " \\ \" \'"] fn bar () {}"#,
);
}
#[test]
fn test_tt_block() {
parse_macro(