Delete OrthoSize, and run the seeds in parallel
A span is as long across itself as its longest child, unless a rule beside it already says how long it is -- and then reading the children answers nothing and only makes its size depend on theirs. `OrthoSize::Full` was that second case written twice, once as an enum on the span and once as the rule that actually decides; `Painter::ruled` lets the span ask which it is in. The widget under a rule still does not learn what the rule says, only that its answer for that axis is not wanted. The fuzzers grow, lay out and drop a tree within one seed, so the seeds share nothing and take a thread each, one short of every core. Measured here: the generated oracle's hundred seeds went from 68 s to 10 s, and a shrinker case at 300 seeds from 18 s to 3.5 s. A seed that fails still shrinks and panics on its own thread, and `std::thread::scope` carries that out. The shrinker now allows the two steps the oracle already did -- the deeper trees these grow reach a second composition, and a step is a thousandth of a pixel. Checked: fmt, clippy, 102 tests, all five shrinker cases at 300 seeds, 100 generated seeds, and five examples byte-identical at 1920x1200. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb955f1023
commit
9d8415d65f
8 files changed
+94
-74
No files matched your search
+5
-14
@@ -21,27 +21,21 @@ fn a_span_gives_each_child_the_width_it_asked_for() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_full_ortho_span_reports_relative_full() {
|
||||
fn a_span_ruled_across_itself_does_not_measure_its_children_there() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let child = rect(Color::RED).height(40).add(&mut h.rsc);
|
||||
let span = (child,)
|
||||
.span(Dir::RIGHT)
|
||||
.ortho(OrthoSize::Full)
|
||||
.add(&mut h.rsc);
|
||||
let span = (child,).span(Dir::RIGHT).height(rel(1.0)).add(&mut h.rsc);
|
||||
h.set_root(span);
|
||||
|
||||
assert_eq!(h.render.active[&span.id()].size.y, Len::rel(1.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_children_ortho_span_reports_its_tallest_fixed_child() {
|
||||
fn a_span_reports_its_tallest_fixed_child() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let short = rect(Color::RED).height(40).add(&mut h.rsc);
|
||||
let tall = rect(Color::BLUE).height(70).add(&mut h.rsc);
|
||||
let span = (short, tall)
|
||||
.span(Dir::RIGHT)
|
||||
.ortho(OrthoSize::Children)
|
||||
.add(&mut h.rsc);
|
||||
let span = (short, tall).span(Dir::RIGHT).add(&mut h.rsc);
|
||||
h.set_root(span);
|
||||
|
||||
assert_eq!(h.render.active[&span.id()].size.y, Len::px(70.0));
|
||||
@@ -211,10 +205,7 @@ fn a_box_with_a_fixed_length_can_be_stretched_on_its_other_axis() {
|
||||
let filler = rect(Color::GREEN).add(&mut h.rsc);
|
||||
// This column is an item in a row, so it takes the width left for it
|
||||
// rather than asking for a full row-width in addition to the bar.
|
||||
let column = (row, filler)
|
||||
.span(Dir::DOWN)
|
||||
.ortho(OrthoSize::Children)
|
||||
.add(&mut h.rsc);
|
||||
let column = (row, filler).span(Dir::DOWN).add(&mut h.rsc);
|
||||
let bar = rect(Color::RED).width(100).add(&mut h.rsc);
|
||||
h.set_root((bar, column).span(Dir::RIGHT));
|
||||
assert_corners!(h, inner, (110, 10), (390, 30));
|
||||
|
||||
@@ -300,13 +300,10 @@ fn a_resize_does_not_redraw_what_the_shader_can_move() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_full_ortho_span_moves_its_child_without_redrawing_it() {
|
||||
fn a_span_ruled_across_itself_moves_its_child_without_redrawing_it() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let (leaf, draws) = counted(&mut h, Size::LEFTOVER, false);
|
||||
let span = (leaf,)
|
||||
.span(Dir::RIGHT)
|
||||
.ortho(OrthoSize::Full)
|
||||
.add(&mut h.rsc);
|
||||
let span = (leaf,).span(Dir::RIGHT).height(rel(1.0)).add(&mut h.rsc);
|
||||
h.set_root(span);
|
||||
let settled = draws.get();
|
||||
|
||||
|
||||
@@ -160,7 +160,6 @@ fn plant_pair(h: &mut Harness, swapped: bool) -> (Vec<WidgetId>, WeakWidget<Span
|
||||
children,
|
||||
dir: Dir::RIGHT,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
let span_handle = span;
|
||||
@@ -214,7 +213,6 @@ fn plant_scrolled(h: &mut Harness, swapped: bool) -> (Vec<WidgetId>, [WeakWidget
|
||||
children: inner_children,
|
||||
dir: Dir::RIGHT,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
let block = rect(Color::RED).add(&mut h.rsc);
|
||||
@@ -228,7 +226,6 @@ fn plant_scrolled(h: &mut Harness, swapped: bool) -> (Vec<WidgetId>, [WeakWidget
|
||||
children: outer_children,
|
||||
dir: Dir::RIGHT,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
// Carried no rule even before rules were a property: it is here to be a
|
||||
@@ -337,7 +334,6 @@ fn plant_boundary(h: &mut Harness, swapped: bool) -> (Vec<WidgetId>, [WeakWidget
|
||||
children: pair,
|
||||
dir: Dir::DOWN,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
// Takes the whole box on its own, so the span above has nothing left to
|
||||
@@ -357,7 +353,6 @@ fn plant_boundary(h: &mut Harness, swapped: bool) -> (Vec<WidgetId>, [WeakWidget
|
||||
children: inner_children,
|
||||
dir: Dir::DOWN,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
.add(&mut h.rsc);
|
||||
h.rsc
|
||||
|
||||
Reference in new issue
Block a user