Removes */ in block doc comments

This commit is contained in:
kjeremy 2019-07-31 11:43:00 -04:00
parent 7c0a9718aa
commit d65dc40348
2 changed files with 62 additions and 2 deletions

View file

@ -138,6 +138,55 @@ fn test_doc_comment_preserves_newlines() {
assert_eq!("this\nis\nmod\nfoo", module.doc_comment_text().unwrap());
}
#[test]
fn test_doc_comment_single_line_block_strips_suffix() {
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 is mod foo", module.doc_comment_text().unwrap());
}
#[test]
fn test_doc_comment_single_line_block_strips_suffix_whitespace() {
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 is mod foo", module.doc_comment_text().unwrap());
}
#[test]
fn test_doc_comment_multi_line_block_strips_suffix() {
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\n is\n mod foo\n ",
module.doc_comment_text().unwrap()
);
}
#[test]
fn test_where_predicates() {
fn assert_bound(text: &str, bound: Option<TypeBound>) {