mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-12 23:13:15 +00:00
Merge #1629
1629: Add explicit newline preserving tests r=matklad a=kjeremy I didn't see anything that explicitly called this out so added tests. Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
commit
7c0a9718aa
@ -48,4 +48,10 @@ mod tests {
|
||||
let comment = " # stay1\n# stay2\n#stay3\nstay4\n#\n #\n # \n #\tstay5\n\t#\t";
|
||||
assert_eq!(format_docs(comment), comment);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_docs_preserves_newlines() {
|
||||
let comment = "this\nis\nultiline";
|
||||
assert_eq!(format_docs(comment), comment);
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,23 @@ fn test_doc_comment_preserves_indents() {
|
||||
assert_eq!("doc1\n```\nfn foo() {\n // ...\n}\n```", module.doc_comment_text().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_doc_comment_preserves_newlines() {
|
||||
let file = SourceFile::parse(
|
||||
r#"
|
||||
/// this
|
||||
/// is
|
||||
/// mod
|
||||
/// foo
|
||||
mod foo {}
|
||||
"#,
|
||||
)
|
||||
.ok()
|
||||
.unwrap();
|
||||
let module = file.syntax().descendants().find_map(Module::cast).unwrap();
|
||||
assert_eq!("this\nis\nmod\nfoo", module.doc_comment_text().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_where_predicates() {
|
||||
fn assert_bound(text: &str, bound: Option<TypeBound>) {
|
||||
|
Loading…
Reference in New Issue
Block a user