]>
Commit | Line | Data |
---|---|---|
1b1a35ee | 1 | use super::write_code; |
5869c6ff | 2 | use crate::html::format::Buffer; |
1b1a35ee | 3 | use expect_test::expect_file; |
136023e0 | 4 | use rustc_span::create_default_session_globals_then; |
fc512014 | 5 | use rustc_span::edition::Edition; |
3dfed10e | 6 | |
1b1a35ee XL |
7 | const STYLE: &str = r#" |
8 | <style> | |
9 | .kw { color: #8959A8; } | |
10 | .kw-2, .prelude-ty { color: #4271AE; } | |
11 | .number, .string { color: #718C00; } | |
12 | .self, .bool-val, .prelude-val, .attribute, .attribute .ident { color: #C82829; } | |
13 | .macro, .macro-nonterminal { color: #3E999F; } | |
14 | .lifetime { color: #B76514; } | |
15 | .question-mark { color: #ff9011; } | |
16 | </style> | |
17 | "#; | |
2a314972 XL |
18 | |
19 | #[test] | |
20 | fn test_html_highlighting() { | |
136023e0 | 21 | create_default_session_globals_then(|| { |
17df50a5 XL |
22 | let src = include_str!("fixtures/sample.rs"); |
23 | let html = { | |
24 | let mut out = Buffer::new(); | |
25 | write_code(&mut out, src, Edition::Edition2018); | |
26 | format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner()) | |
27 | }; | |
28 | expect_file!["fixtures/sample.html"].assert_eq(&html); | |
29 | }); | |
2a314972 XL |
30 | } |
31 | ||
32 | #[test] | |
33 | fn test_dos_backline() { | |
136023e0 | 34 | create_default_session_globals_then(|| { |
17df50a5 | 35 | let src = "pub fn foo() {\r\n\ |
2a314972 XL |
36 | println!(\"foo\");\r\n\ |
37 | }\r\n"; | |
17df50a5 XL |
38 | let mut html = Buffer::new(); |
39 | write_code(&mut html, src, Edition::Edition2018); | |
40 | expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner()); | |
41 | }); | |
2a314972 | 42 | } |