Skip to content

Commit

Permalink
add test for array fix
Browse files Browse the repository at this point in the history
  • Loading branch information
carloskiki committed Aug 4, 2024
1 parent a98e642 commit 9261a0d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 77 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ name = "cross-browser"
path = "tests/cross-browser.rs"
harness = false

[[test]]
name = "environments"
path = "tests/environments.rs"
harness = false

[[bench]]
name = "basic"
harness = false
Expand Down
48 changes: 48 additions & 0 deletions tests/environments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use std::{fs::File, path::Path};

use common::{html_template, tabled, OUTPUT_DIR};

mod common;

fn main() {
let concl = common::test();
if std::env::var("RENDER").as_deref() != Ok("true") {
concl.exit()
}

let mut file = File::create(Path::new(OUTPUT_DIR).join("environments.html")).unwrap();
html_template(&mut file, "Mathematical Environments Tests", None, tabled).unwrap();

concl.exit();
}

macro_rules! round_trip_display {
($name:ident, $($input:literal),+ $(,)?) => {
$crate::round_trip!(
$name,
$($input),+,
display_mode = pulldown_latex::config::DisplayMode::Block
);
};
(should_panic, $name:ident, $($input:literal),+ $(,)?) => {
$crate::round_trip!(
should_panic,
$name,
$($input),+
);
}
}

round_trip_display!(arrays,
r#"\begin{array}{||c|r|l||}
a + b \\[2em]
a + b & c & d \\[2em] \hline
a + b
\end{array}"#,
r#"\begin{array}{c:c:c}
a & b & c \\ \hline
d & e & f \\
\hdashline
g & h & i
\end{array}"#,
);
19 changes: 19 additions & 0 deletions tests/out/environments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Mathematical Environments Tests</title>
<link rel="stylesheet" type="text/css" href="/Users/charles/Code/rust/pulldown-latex/styles.css">
<meta charset="UTF-8">
</head>
<body>
<table style="max-width: 60vw; margin: auto;"><tr><th colspan="2">Arrays</th></tr><tr><td>\begin{array}{||c|r|l||}
a + b \\[2em]
a + b & c & d \\[2em] \hline
a + b
\end{array}</td><td style="position: relative"><math display="block"><mtable class="menv-arraylike"><mtr><mtd class="menv-left-solid menv-border-only"></mtd><mtd class="menv-left-solid menv-right-solid"><mi>a</mi><mo>+</mo><mi>b</mi></mtd></mtr><mtr style="height: 2em"><mtd class="menv-left-solid menv-border-only"></mtd><mtd class="menv-left-solid menv-right-solid"></mtd></mtr><mtr><mtd class="menv-left-solid menv-border-only"></mtd><mtd class="menv-left-solid menv-right-solid"><mi>a</mi><mo>+</mo><mi>b</mi></mtd><mtd class="cell-right menv-right-solid"><mi>c</mi></mtd><mtd class="cell-left menv-right-solid"><mi>d</mi></mtd><mtd class="menv-right-solid menv-border-only"></mtd></mtr><mtr style="height: 2em"><mtd class="menv-left-solid menv-border-only"></mtd><mtd class="menv-left-solid menv-right-solid"></mtd><mtd class="cell-right menv-right-solid"></mtd><mtd class="cell-left menv-right-solid"></mtd><mtd class="menv-right-solid menv-border-only"></mtd></mtr><mtr class="menv-hline"><mtd class="menv-left-solid menv-border-only"></mtd><mtd class="menv-left-solid menv-right-solid"><mi>a</mi><mo>+</mo><mi>b</mi></mtd></mtr></mtable></math></td></tr><tr><td>\begin{array}{c:c:c}
a & b & c \\ \hline
d & e & f \\
\hdashline
g & h & i
\end{array}</td><td style="position: relative"><math display="block"><mtable class="menv-arraylike"><mtr><mtd class="menv-right-dashed"><mi>a</mi></mtd><mtd class="menv-right-dashed"><mi>b</mi></mtd><mtd><mi>c</mi></mtd></mtr><mtr class="menv-hline"><mtd class="menv-right-dashed"><mi>d</mi></mtd><mtd class="menv-right-dashed"><mi>e</mi></mtd><mtd><mi>f</mi></mtd></mtr><mtr class="menv-hdashline"><mtd class="menv-right-dashed"><mi>g</mi></mtd><mtd class="menv-right-dashed"><mi>h</mi></mtd><mtd><mi>i</mi></mtd></mtr></mtable></math></td></tr></table></body>
</html>
3 changes: 2 additions & 1 deletion tests/out/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<body>
<a href="wikipedia.html">Wikipedia tests</a>
<a href="mozilla.html">Mozilla tests</a>
<a href="cross-browser.html">Cross Browser tests</a>
<a href="cross-browser.html">Cross-Browser tests</a>
<a href="environments.html">Environments tests</a>
</body>
</html>
Loading

0 comments on commit 9261a0d

Please sign in to comment.