Promote verified native PDF and box capacity support
This commit is contained in:
1 parent
3706afa483
commit
72ed779749
31 files changed
+1042
-78
No files matched your search
@@ -34,6 +34,101 @@ fn messages(e: &Execution) -> Vec<String> {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transferred_nodes_can_be_repacked_without_spending_the_live_box_capacity() {
|
||||
// Match the captured INITEX shape of the CVPR box-capacity reproducer.
|
||||
let material = r"\kern1sp".repeat(500);
|
||||
let source = format!(
|
||||
r"\catcode123=1 \catcode125=2
|
||||
\setbox2=\vbox{{\hrule width2pt height2pt {material}}}
|
||||
\def\repack{{\ifnum\count0<2050 \advance\count0 by1
|
||||
\setbox2=\vbox{{\unvbox2}}\expandafter\repack\fi}}
|
||||
\repack
|
||||
\message{{REPACKED=\number\count0|BOX=\number\wd2,\number\ht2,\number\dp2}}
|
||||
\shipout\box2 \end"
|
||||
);
|
||||
let execution = Executor::new(
|
||||
State::initex().with_etex(),
|
||||
Limits {
|
||||
steps: 2_000_000,
|
||||
..Limits::default()
|
||||
},
|
||||
)
|
||||
.with_native_pages()
|
||||
.run(
|
||||
SourceFile {
|
||||
name: "repack.tex".into(),
|
||||
data: source.into_bytes(),
|
||||
},
|
||||
&mut NoFiles,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(messages(&execution), ["REPACKED=2050|BOX=131072,131572,0"]);
|
||||
let pages: Vec<_> = execution
|
||||
.events
|
||||
.iter()
|
||||
.filter_map(|event| match event {
|
||||
Event::Shipout(page) => Some(page),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(pages.len(), 1);
|
||||
assert_eq!(pages[0].box_node.node_count(), 502);
|
||||
assert!(execution.state.box_register(2).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn box_capacity_checks_live_copies_retained_pages_and_single_boxes() {
|
||||
let material = r"\kern1sp".repeat(40);
|
||||
let run = |body: &str| {
|
||||
Executor::new(
|
||||
State::initex().with_etex(),
|
||||
Limits {
|
||||
tokens: 64,
|
||||
..Limits::default()
|
||||
},
|
||||
)
|
||||
.with_native_pages()
|
||||
.run_detailed(
|
||||
SourceFile {
|
||||
name: "box-capacity.tex".into(),
|
||||
data: format!(r"\catcode123=1 \catcode125=2 {body}\end").into_bytes(),
|
||||
},
|
||||
&mut NoFiles,
|
||||
)
|
||||
};
|
||||
let over = [
|
||||
(format!(r"\setbox0=\vbox{{{material}{material}}}"), 0),
|
||||
(format!(r"\setbox0=\vbox{{{material}}}\setbox1=\copy0"), 0),
|
||||
(
|
||||
format!(r"\shipout\vbox{{{material}}}\shipout\vbox{{{material}}}"),
|
||||
1,
|
||||
),
|
||||
];
|
||||
for (body, retained) in over {
|
||||
let failed = run(&body).unwrap_err();
|
||||
assert!(
|
||||
failed
|
||||
.error
|
||||
.message
|
||||
.contains("native box node capacity exceeded"),
|
||||
"{}",
|
||||
failed.error
|
||||
);
|
||||
let published = failed
|
||||
.evidence
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| matches!(event, Event::Shipout(_)))
|
||||
.count();
|
||||
assert_eq!(published, retained);
|
||||
}
|
||||
let body = format!(r"\setbox0=\vbox{{{material}}}\setbox0=\vbox{{{material}}}");
|
||||
let final_box = run(&body).unwrap().state.box_register(0).unwrap().clone();
|
||||
assert_eq!(final_box.node_count(), 41);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn box_registers_scopes_moves_and_dimensions_preserve_native_contents() {
|
||||
let e = run(
|
||||
|
||||
Reference in new issue
Block a user