layout tests: each edge of the bound refuses
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 4m27s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 3m34s

This commit is contained in:
Meta Vens 2026-11-28 06:24:07 +01:00
commit d338f23356

View file

@ -953,3 +953,21 @@ fn large_siblings_on_one_axis_are_exact_or_refused() {
}
assert!(exact > 0 && refused > 0, "exact {exact}, refused {refused}");
}
#[test]
fn each_edge_of_the_precision_bound_refuses() {
let refused = |root: Node| {
let tree = bind(&mut MemState::new(), &surface_of(root)).unwrap();
matches!(layout(&tree, &pixels(800.0, 600.0, 1.0), &mut FixedMeasure::pixels(&[])), Err(LayoutError::OutOfRange(_)))
};
let column = BoxStyle { direction: Direction::Column, ..plain() };
// The bottom edge alone is past the bound: the top is not.
assert!(refused(bx("root", column.clone(), vec![embed("a", 10.0, 16.0), embed("b", 10.0, 2_097_152.0)])));
// The right edge alone.
assert!(refused(bx("root", plain(), vec![embed("a", 16.0, 10.0), embed("b", 2_097_152.0, 10.0)])));
// A position past the bound on the negative side.
let pull = BoxStyle { margin: Edges { left: px(-2_097_152.0), ..edges(px(0.0)) }, ..plain() };
assert!(refused(bx("root", plain(), vec![bx("outer", pull.clone(), vec![bx("inner", pull, vec![embed("e", 1.0, 1.0)])])])));
// Whole layouts at the bound are fine.
assert!(!refused(bx("root", column, vec![embed("a", 10.0, 2_097_152.0)])));
}