mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
move tests
This commit is contained in:
parent
7e53a3ce23
commit
a3470a8114
@ -131,6 +131,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
|
|||||||
(T![,], _) => " ",
|
(T![,], _) => " ",
|
||||||
(T![fn], T!['(']) => "",
|
(T![fn], T!['(']) => "",
|
||||||
(T![']'], _) if curr_kind.is_keyword() => " ",
|
(T![']'], _) if curr_kind.is_keyword() => " ",
|
||||||
|
(T![']'], T![#]) => "\n",
|
||||||
_ if prev_kind.is_keyword() => " ",
|
_ if prev_kind.is_keyword() => " ",
|
||||||
_ => "",
|
_ => "",
|
||||||
};
|
};
|
||||||
|
@ -956,3 +956,90 @@ macro_rules! m {
|
|||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_meta_doc_comments() {
|
||||||
|
cov_mark::check!(test_meta_doc_comments);
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
m! {
|
||||||
|
/// Single Line Doc 1
|
||||||
|
/**
|
||||||
|
MultiLines Doc
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r##"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
#[doc = " Single Line Doc 1"]
|
||||||
|
#[doc = "\n MultiLines Doc\n "] fn bar() {}
|
||||||
|
"##]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_meta_extended_key_value_attributes() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
(#[$m:meta]) => ( #[$m] fn bar() {} )
|
||||||
|
}
|
||||||
|
m! { #[doc = concat!("The `", "bla", "` lang item.")] }
|
||||||
|
"#,
|
||||||
|
expect![[r##"
|
||||||
|
macro_rules! m {
|
||||||
|
(#[$m:meta]) => ( #[$m] fn bar() {} )
|
||||||
|
}
|
||||||
|
#[doc = concat!("The `", "bla", "` lang item.")] fn bar() {}
|
||||||
|
"##]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_meta_doc_comments_non_latin() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$ m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
m! {
|
||||||
|
/// 錦瑟無端五十弦,一弦一柱思華年。
|
||||||
|
/**
|
||||||
|
莊生曉夢迷蝴蝶,望帝春心託杜鵑。
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r##"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$ m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
#[doc = " 錦瑟無端五十弦,一弦一柱思華年。"]
|
||||||
|
#[doc = "\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\n "] fn bar() {}
|
||||||
|
"##]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_meta_doc_comments_escaped_characters() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
m! {
|
||||||
|
/// \ " '
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r##"
|
||||||
|
macro_rules! m {
|
||||||
|
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
|
||||||
|
}
|
||||||
|
#[doc = " \\ \" \'"] fn bar() {}
|
||||||
|
"##]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -307,6 +307,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn convert_doc_comment(token: &syntax::SyntaxToken) -> Option<Vec<tt::TokenTree>> {
|
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 comment = ast::Comment::cast(token.clone())?;
|
||||||
let doc = comment.kind().doc?;
|
let doc = comment.kind().doc?;
|
||||||
|
|
||||||
|
@ -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]
|
#[test]
|
||||||
fn test_tt_block() {
|
fn test_tt_block() {
|
||||||
parse_macro(
|
parse_macro(
|
||||||
|
Loading…
Reference in New Issue
Block a user