]> git.lizzy.rs Git - rust.git/blob - src/librustc_ast/util/comments/tests.rs
Fix font color for help button in ayu and dark themes
[rust.git] / src / librustc_ast / util / comments / tests.rs
1 use super::*;
2 use rustc_span::with_default_session_globals;
3
4 #[test]
5 fn line_doc_comments() {
6     assert!(line_doc_comment_style("///").is_some());
7     assert!(line_doc_comment_style("/// blah").is_some());
8     assert!(line_doc_comment_style("////").is_none());
9 }
10
11 #[test]
12 fn test_block_doc_comment_1() {
13     with_default_session_globals(|| {
14         let comment = "\n * Test \n **  Test\n *   Test\n";
15         let stripped = beautify_doc_string(Symbol::intern(comment));
16         assert_eq!(stripped, " Test \n*  Test\n   Test");
17     })
18 }
19
20 #[test]
21 fn test_block_doc_comment_2() {
22     with_default_session_globals(|| {
23         let comment = "\n * Test\n *  Test\n";
24         let stripped = beautify_doc_string(Symbol::intern(comment));
25         assert_eq!(stripped, " Test\n  Test");
26     })
27 }
28
29 #[test]
30 fn test_block_doc_comment_3() {
31     with_default_session_globals(|| {
32         let comment = "\n let a: *i32;\n *a = 5;\n";
33         let stripped = beautify_doc_string(Symbol::intern(comment));
34         assert_eq!(stripped, " let a: *i32;\n *a = 5;");
35     })
36 }
37
38 #[test]
39 fn test_line_doc_comment() {
40     with_default_session_globals(|| {
41         let stripped = beautify_doc_string(Symbol::intern(" test"));
42         assert_eq!(stripped, " test");
43         let stripped = beautify_doc_string(Symbol::intern("! test"));
44         assert_eq!(stripped, "! test");
45         let stripped = beautify_doc_string(Symbol::intern("test"));
46         assert_eq!(stripped, "test");
47         let stripped = beautify_doc_string(Symbol::intern("!test"));
48         assert_eq!(stripped, "!test");
49     })
50 }