Thing 2.0 cut 6b: a zero-sided asset is judged alone

This commit is contained in:
Meta Vens 2026-11-28 08:21:40 +01:00
commit 6734bd8e91

View file

@ -836,7 +836,7 @@ fn a_missing_asset_is_one_placeholder_and_no_image_command() {
// No catalog (Absent), an entry the catalog lacks (Error), and a 0x0 entry.
state.put(&provider, &catalog(&[("empty", 0, 0), ("sliver", 0, 10)]));
let mut root = vec![Node::Image(ImageNode { common: common("absent"), catalog: "nowhere".into(), asset: "x".into(), fit: ImageFit::Fill, alt: lit_text("alt") })];
for (id, asset) in [("lacks", "nothing"), ("empty", "empty"), ("sliver", "sliver")] {
for (id, asset) in [("lacks", "nothing"), ("empty", "empty")] {
root.push(image(id, asset, ImageFit::Contain));
}
let out = with_state(&mut state, flat("root", plain(), root), &pixels(1.0));
@ -847,8 +847,11 @@ fn a_missing_asset_is_one_placeholder_and_no_image_command() {
RenderCommand::StrokeRect { rect: none, radius: 0.0, width: 1.0, color: color("thing.error") },
]
};
let four: Vec<_> = (0..4).flat_map(|_| placeholder()).collect();
assert_eq!(out.commands, four, "no catalog (Absent), a missing entry (Error), a 0x0 entry and one with a zero side");
let three: Vec<_> = (0..3).flat_map(|_| placeholder()).collect();
assert_eq!(out.commands, three, "no catalog (Absent), a missing entry (Error) and a 0x0 entry");
// One zero side is no extent either.
let out = with_state(&mut state, flat("root", plain(), vec![image("sliver", "sliver", ImageFit::Contain)]), &pixels(1.0));
assert!(!out.commands.iter().any(|c| matches!(c, RenderCommand::Image { .. })), "{:?}", out.commands);
// Where the placeholder has height but no width, the alt text has nowhere to go.
let mut state = MemState::new();
state.put(&provider, &catalog(&[("empty", 0, 0)]));