2 use crate::html::format::Buffer;
3 use expect_test::expect_file;
4 use rustc_span::create_default_session_globals_then;
5 use rustc_span::edition::Edition;
7 const STYLE: &str = r#"
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; }
20 fn test_html_highlighting() {
21 create_default_session_globals_then(|| {
22 let src = include_str!("fixtures/sample.rs");
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())
28 expect_file!["fixtures/sample.html"].assert_eq(&html);
33 fn test_dos_backline() {
34 create_default_session_globals_then(|| {
35 let src = "pub fn foo() {\r\n\
36 println!(\"foo\");\r\n\
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());