Merge pull request #6936

This commit is contained in:
autocraft-bot[bot]
2026-12-02 07:39:07 +00:00
+7 -1
View File
@@ -3935,7 +3935,13 @@ fn kept_headings_measure_the_next_paragraph_through_the_cache() {
let mut c = LayoutCache::new();
let proofed = layout(&d, &mut c, &LayoutOptions { proofing: true, ..Default::default() });
assert_eq!(c.misses, d.body.len() as u64, "each paragraph laid out once with proofing on");
assert!(c.hits >= 40, "each kept heading should reuse its following paragraph layout with proofing on; got {} cache hits", c.hits);
// A kept heading that falls to the next page skips the pre-measure, once per page break at most.
let pre_measured = 40u64.saturating_sub(l.pages.len() as u64).max(1);
assert!(
c.hits >= pre_measured,
"kept headings should reuse their following paragraph layout with proofing on; got {} cache hits of at least {pre_measured}",
c.hits
);
let starts = |l: &DocLayout| (0..d.body.len()).map(|i| l.caret(&Pos::body(i, 0)).map(|c| (c.page, c.top.to_bits()))).collect::<Vec<_>>();
assert_eq!(starts(&l), starts(&proofed));
}