about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/util/comments
diff options
context:
space:
mode:
authormark <markm@cs.wisc.edu>2020-08-27 22:58:48 -0500
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-08-30 18:45:07 +0300
commit9e5f7d5631b8f4009ac1c693e585d4b7108d4275 (patch)
tree158a05eb3f204a8e72939b58427d0c2787a4eade /compiler/rustc_ast/src/util/comments
parentdb534b3ac286cf45688c3bbae6aa6e77439e52d2 (diff)
mv compiler to compiler/
Diffstat (limited to 'compiler/rustc_ast/src/util/comments')
-rw-r--r--compiler/rustc_ast/src/util/comments/tests.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/util/comments/tests.rs b/compiler/rustc_ast/src/util/comments/tests.rs
new file mode 100644
index 00000000000..e19198f863b
--- /dev/null
+++ b/compiler/rustc_ast/src/util/comments/tests.rs
@@ -0,0 +1,43 @@
+use super::*;
+use rustc_span::with_default_session_globals;
+
+#[test]
+fn test_block_doc_comment_1() {
+    with_default_session_globals(|| {
+        let comment = "\n * Test \n **  Test\n *   Test\n";
+        let stripped = beautify_doc_string(Symbol::intern(comment));
+        assert_eq!(stripped, " Test \n*  Test\n   Test");
+    })
+}
+
+#[test]
+fn test_block_doc_comment_2() {
+    with_default_session_globals(|| {
+        let comment = "\n * Test\n *  Test\n";
+        let stripped = beautify_doc_string(Symbol::intern(comment));
+        assert_eq!(stripped, " Test\n  Test");
+    })
+}
+
+#[test]
+fn test_block_doc_comment_3() {
+    with_default_session_globals(|| {
+        let comment = "\n let a: *i32;\n *a = 5;\n";
+        let stripped = beautify_doc_string(Symbol::intern(comment));
+        assert_eq!(stripped, " let a: *i32;\n *a = 5;");
+    })
+}
+
+#[test]
+fn test_line_doc_comment() {
+    with_default_session_globals(|| {
+        let stripped = beautify_doc_string(Symbol::intern(" test"));
+        assert_eq!(stripped, " test");
+        let stripped = beautify_doc_string(Symbol::intern("! test"));
+        assert_eq!(stripped, "! test");
+        let stripped = beautify_doc_string(Symbol::intern("test"));
+        assert_eq!(stripped, "test");
+        let stripped = beautify_doc_string(Symbol::intern("!test"));
+        assert_eq!(stripped, "!test");
+    })
+}