Skip to content

Commit

Permalink
Add test for block doc comments horizontal trim
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 7, 2022
1 parent e394287 commit 33cbf89
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
20 changes: 6 additions & 14 deletions compiler/rustc_ast/src/util/comments/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,17 @@ fn test_line_doc_comment() {
#[test]
fn test_doc_blocks() {
create_default_session_globals_then(|| {
let stripped = beautify_doc_string(
Symbol::intern(
" # Returns
*
",
),
CommentKind::Block,
);
let stripped =
beautify_doc_string(Symbol::intern(" # Returns\n *\n "), CommentKind::Block);
assert_eq!(stripped.as_str(), " # Returns\n\n");

let stripped = beautify_doc_string(
Symbol::intern(
"
* # Returns
*
",
),
Symbol::intern("\n * # Returns\n *\n "),
CommentKind::Block,
);
assert_eq!(stripped.as_str(), " # Returns\n\n");

let stripped = beautify_doc_string(Symbol::intern("\n * a\n "), CommentKind::Block);
assert_eq!(stripped.as_str(), " a\n");
})
}
16 changes: 16 additions & 0 deletions src/test/rustdoc-ui/block-doc-comment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass
// compile-flags:--test

// This test ensures that no code block is detected in the doc comments.

pub mod Wormhole {
/** # Returns
*
*/
pub fn foofoo() {}
/**
* # Returns
*
*/
pub fn barbar() {}
}
5 changes: 5 additions & 0 deletions src/test/rustdoc-ui/block-doc-comment.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

0 comments on commit 33cbf89

Please sign in to comment.