]> git.lizzy.rs Git - rust.git/commitdiff
Add test for block doc comments horizontal trim
authorGuillaume Gomez <guillaume.gomez@huawei.com>
Sun, 6 Feb 2022 21:21:09 +0000 (22:21 +0100)
committerGuillaume Gomez <guillaume.gomez@huawei.com>
Mon, 7 Feb 2022 16:07:53 +0000 (17:07 +0100)
compiler/rustc_ast/src/util/comments/tests.rs
src/test/rustdoc-ui/block-doc-comment.rs [new file with mode: 0644]
src/test/rustdoc-ui/block-doc-comment.stdout [new file with mode: 0644]

index 0b8772947e6e95850e9c41e6cfc030ac803d57d6..11d50603a1011fb84f483c82731bce45664789d8 100644 (file)
@@ -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");
     })
 }
diff --git a/src/test/rustdoc-ui/block-doc-comment.rs b/src/test/rustdoc-ui/block-doc-comment.rs
new file mode 100644 (file)
index 0000000..c60dfa3
--- /dev/null
@@ -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() {}
+}
diff --git a/src/test/rustdoc-ui/block-doc-comment.stdout b/src/test/rustdoc-ui/block-doc-comment.stdout
new file mode 100644 (file)
index 0000000..e5c27be
--- /dev/null
@@ -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
+