summary refs log tree commit diff
path: root/compiler/rustc_ast/src/util/comments/tests.rs
blob: 6d137f3774fe76a6fe801557956602223e4a3963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::*;
use rustc_span::create_default_session_globals_then;

#[test]
fn test_block_doc_comment_1() {
    create_default_session_globals_then(|| {
        let comment = "\n * Test \n **  Test\n *   Test\n";
        let stripped = beautify_doc_string(Symbol::intern(comment));
        assert_eq!(stripped.as_str(), " Test \n*  Test\n   Test");
    })
}

#[test]
fn test_block_doc_comment_2() {
    create_default_session_globals_then(|| {
        let comment = "\n * Test\n *  Test\n";
        let stripped = beautify_doc_string(Symbol::intern(comment));
        assert_eq!(stripped.as_str(), " Test\n  Test");
    })
}

#[test]
fn test_block_doc_comment_3() {
    create_default_session_globals_then(|| {
        let comment = "\n let a: *i32;\n *a = 5;\n";
        let stripped = beautify_doc_string(Symbol::intern(comment));
        assert_eq!(stripped.as_str(), " let a: *i32;\n *a = 5;");
    })
}

#[test]
fn test_line_doc_comment() {
    create_default_session_globals_then(|| {
        let stripped = beautify_doc_string(Symbol::intern(" test"));
        assert_eq!(stripped.as_str(), " test");
        let stripped = beautify_doc_string(Symbol::intern("! test"));
        assert_eq!(stripped.as_str(), "! test");
        let stripped = beautify_doc_string(Symbol::intern("test"));
        assert_eq!(stripped.as_str(), "test");
        let stripped = beautify_doc_string(Symbol::intern("!test"));
        assert_eq!(stripped.as_str(), "!test");
    })
}