mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
move tests
This commit is contained in:
parent
7e53a3ce23
commit
a3470a8114
4 changed files with 89 additions and 84 deletions
|
@ -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?;
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue