Update highlight tests

This commit is contained in:
Guillaume Gomez 2021-05-05 18:13:47 +02:00
parent ad4ccf966b
commit 3c489a3482

View File

@ -2,6 +2,7 @@ use super::write_code;
use crate::html::format::Buffer;
use expect_test::expect_file;
use rustc_span::edition::Edition;
use rustc_span::with_default_session_globals;
const STYLE: &str = r#"
<style>
@ -17,21 +18,25 @@ const STYLE: &str = r#"
#[test]
fn test_html_highlighting() {
let src = include_str!("fixtures/sample.rs");
let html = {
let mut out = Buffer::new();
write_code(&mut out, src, Edition::Edition2018);
format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner())
};
expect_file!["fixtures/sample.html"].assert_eq(&html);
with_default_session_globals(|| {
let src = include_str!("fixtures/sample.rs");
let html = {
let mut out = Buffer::new();
write_code(&mut out, src, Edition::Edition2018);
format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner())
};
expect_file!["fixtures/sample.html"].assert_eq(&html);
});
}
#[test]
fn test_dos_backline() {
let src = "pub fn foo() {\r\n\
with_default_session_globals(|| {
let src = "pub fn foo() {\r\n\
println!(\"foo\");\r\n\
}\r\n";
let mut html = Buffer::new();
write_code(&mut html, src, Edition::Edition2018);
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
let mut html = Buffer::new();
write_code(&mut html, src, Edition::Edition2018);
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
});
}