Skip to content

Commit

Permalink
Update highlight tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed May 5, 2021
1 parent ad4ccf9 commit 3c489a3
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/librustdoc/html/highlight/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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());
});
}

0 comments on commit 3c489a3

Please sign in to comment.