Preserve conditional math glue through native layout

This commit is contained in:
gloamxun committed 2026-11-29 02:16:50 +08:00
1 parent 91bb864d8c
commit 745c33fd44
18 files changed
+152 -25

No files matched your search

@@ -97,6 +97,31 @@ fn mathcodes_active_characters_families_scripts_and_modes_execute() {
e.state.box_register(1).unwrap().width
);
}
#[test]
fn conditional_math_glue_is_retained_for_list_queries_and_showbox() {
let e = run(r"\setbox0=\hbox{$\scriptstyle a\nonscript
\message{TAIL=\number\lastnodetype,\the\lastskip}%
\hskip4pt b$}
\showboxbreadth=10 \showboxdepth=10 \showbox0
\setbox1=\hbox{$\scriptstyle a\nonscript\unskip\hskip4pt b$}");
assert!(e.events.iter().any(|event| matches!(
event, Event::Message { text, .. } if text == "TAIL=11,0.0pt"
)));
assert!(e.events.iter().any(|event| matches!(
event, Event::ShowBox(record) if record.text.contains(r"\glue(\nonscript)")
)));
let m = math(&e);
assert_eq!(
m[0].horizontal.iter().filter(|node| matches!(node, TextNode::ConditionalMathGlue)).count(),
1,
);
assert!(!m[0].horizontal.iter().any(|node| matches!(node, TextNode::Glue(_))));
assert_eq!(
e.state.box_register(1).unwrap().width - e.state.box_register(0).unwrap().width,
4 * 65_536,
);
}
#[test]
fn incomplete_math_fonts_modes_and_fields_are_strict_errors() {
for body in [
@@ -185,6 +210,16 @@ fn raw_math_geometry_and_hlist_penalties_match_real_initex() {
r"\mathop a+b",
r"\mathinner{a+b}=c",
r"a\mskip3mu plus2mu b",
r"a\nonscript\mskip8mu b",
r"\displaystyle a\nonscript\mkern8mu b",
r"\scriptstyle a\nonscript\mskip8mu b",
r"\scriptscriptstyle a\nonscript\hskip4pt b",
r"a^{b\nonscript\mkern8mu c}",
r"\scriptstyle a\nonscript\penalty0\hskip4pt b",
r"\scriptstyle a\nonscript\textstyle\hskip4pt b",
r"\scriptstyle a\nonscript\mathchoice{}{}{}{}\kern4pt b",
r"\scriptstyle a\nonscript\nonscript\hskip4pt b",
r"\scriptstyle a\nonscript\leaders\hbox{x}\hskip6pt b",
r"a\mkern2mu b",
r"a\kern2pt b",
r"a+\textstyle b",