A full sweep of #19, and the first review off48e04e. `Display for LayoutLen` leaves out every part that is zero, so `LayoutLen::ZERO` printed as the empty string -- and `Debug` forwards to `Display` since the last commit, so the four `assert_eq!`s in `cases/deferred.rs` print nothing where a request of zero is, and `scenario::describe` prints a `.width(0)` rule as `-`, which is what it prints for a widget that has no rule at all. That file exists so a tree a fuzzer found can be written out by hand; a value it cannot say is a hole in the one thing it is for. `Fixed::ceil_from_f32` took `next_up` of a `from_f32` that had already clamped, and `next_up` wraps, so a measurement past the top of the grid came back as the bottom of it. `from_f32` clamps deliberately because a float has further to come from; the ceiling is the other way in from a float and now holds to the same rule. The check goes beside the one `from_f32` already had. `Moves::depth` walked the move chain a second way, with its own copy of `CHAIN_LIMIT` and without the assertion `walk` makes; it is `walk` now, so the CPU counts the chain in one place and the shader's constant reaches both. `Harness::set_len` said it set a length "the way `.width()` sets one" and wrote the whole rule instead, dropping any bound beside it. A case that set a bound and then a length would have passed with no bound at all. Three rigs each spelled "one seed, or a range of them" by hand -- the class the eleventh sweep closed for reading a parameter and not for this. There is one `rig::seeds` now. `cases/deferred` was last in `suite.rs`'s otherwise alphabetical list. `diag::outside` writes out `AxisHolds::contains`'s four clauses to say which one refused a reuse; a debug assertion now catches a fifth clause added there and not here, which would leave a refusal counted and unexplained. `Sow::bound`'s comment recorded an open hole reached by seeds 4 and 196 at depth 5 -- but `generated.rs` says seeds stopped naming those trees when the leaves grew images, and 600 depth-5 trees over all sixteen cases agree warm against cold with every bound a fraction. The comment says what is true now and why the generator still grows pixels. Format, workspace clippy under -D warnings with and without layout-diagnostics, 208 ordinary and 212 diagnostic tests (207 and 211 before, plus the one this adds), and the cold dump byte-identical tof48e04eacross all 34,986 boxes. The three seed scans were not run: nothing here can move a box, which the dump confirms. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
124 lines
4.6 KiB
Rust
124 lines
4.6 KiB
Rust
//! Laying a tree out again has to land where growing it that way would.
|
|
//!
|
|
//! Every case is one of `scenario`'s, over the trees `iris::random` grows
|
|
//! from a seed. The fast test takes a handful of seeds and the ignored one
|
|
//! takes as many as it is asked for; both run the same cases the shrinker
|
|
//! does over the same trees, so a seed that fails here is reduced by
|
|
//!
|
|
//! SHRINK_SEED=<seed> SHRINK_DEPTH=<depth> SHRINK_CASE=<case> \
|
|
//! cargo test --release --test shrink -- --ignored --nocapture
|
|
//!
|
|
//! `IRIS_GENERATED_SEED`, `IRIS_GENERATED_SEEDS` and `IRIS_GENERATED_DEPTH`
|
|
//! select what the long run covers.
|
|
|
|
mod rig;
|
|
#[path = "scenario/mod.rs"]
|
|
mod scenario;
|
|
|
|
use iris::random::{Edits, Plan, plan};
|
|
use rig::env;
|
|
use scenario::{ALL, Case, diverges, over_seeds};
|
|
|
|
/// How deep the generator branches. The generator widens two to four ways per
|
|
/// level, so depth is exponential in width and a deep narrow tree is not
|
|
/// reachable by raising this -- it buys more overlap between dependency
|
|
/// paths, not more ancestry.
|
|
fn depth() -> usize {
|
|
env("IRIS_GENERATED_DEPTH", 4)
|
|
}
|
|
|
|
/// The seeds the ordinary tests take: a corpus rather than a set of
|
|
/// regression cases, since a seed names a tree only for as long as the
|
|
/// generator draws the same things in the same order. Adding images to the
|
|
/// leaves moved every one of them, so 20 and 86 -- which once caught a widget
|
|
/// placed twice in a box its parent had already placed it in, and a `Scroll`
|
|
/// fixed point settling differently -- no longer grow those trees. Both
|
|
/// defects are pinned by the shrunk fixtures in `cases/unsettled.rs`, which
|
|
/// are trees rather than numbers.
|
|
const SEEDS: [u64; 10] = [1, 2, 3, 5, 8, 10, 13, 20, 86, 98];
|
|
|
|
fn check(seed: u64, depth: usize, case: Case) {
|
|
check_plan(&plan(seed, depth, &Edits::default()), seed, depth, case);
|
|
}
|
|
|
|
fn check_plan(grown: &Plan, seed: u64, depth: usize, case: Case) {
|
|
if let Some(how) = diverges(grown, case, seed) {
|
|
panic!(
|
|
"seed {seed} at depth {depth} differs after {}: {how}\n\
|
|
reduce it with SHRINK_SEED={seed} SHRINK_DEPTH={depth} \
|
|
SHRINK_CASE={} cargo test --release --test shrink -- --ignored --nocapture",
|
|
case.name(),
|
|
case.name(),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A test per case, and the list of which cases have one, from the same
|
|
/// place. A case the ordinary suite leaves out runs only in the long scan,
|
|
/// which nobody runs by hand.
|
|
macro_rules! cases {
|
|
($($name:ident = $case:expr,)*) => {
|
|
$(
|
|
#[test]
|
|
fn $name() {
|
|
for seed in SEEDS {
|
|
check(seed, depth(), $case);
|
|
}
|
|
}
|
|
)*
|
|
|
|
const NAMED: [Case; [$($case,)*].len()] = [$($case,)*];
|
|
};
|
|
}
|
|
|
|
cases! {
|
|
many_widgets_redrawing_at_once_leaves_every_box_where_it_was = Case::RepaintSome,
|
|
everything_redrawing_at_once_leaves_every_box_where_it_was = Case::Repaint,
|
|
a_resize_lands_where_starting_at_that_size_would = Case::Resize,
|
|
a_resize_and_a_repaint_land_where_starting_that_way_would = Case::ResizeRepaint,
|
|
a_size_change_after_a_resize_lands_the_same_way = Case::ResizeSize,
|
|
a_resize_after_a_size_change_lands_the_same_way = Case::SizeResize,
|
|
a_size_change_lands_where_growing_it_that_way_would = Case::Size,
|
|
every_size_changing_at_once_lands_where_growing_it_that_way_would = Case::EverySize,
|
|
an_alignment_change_lands_where_growing_it_that_way_would = Case::Align,
|
|
giving_and_taking_a_movable_region_rebuilds_what_resolves_it = Case::RegionNode,
|
|
reordering_a_span_lands_where_growing_it_that_way_would = Case::Reorder,
|
|
}
|
|
|
|
/// The shuffles are one test between them, so they are the only cases `ALL`
|
|
/// may hold without a test of their own.
|
|
#[test]
|
|
fn every_case_runs_without_the_long_scan() {
|
|
for case in ALL {
|
|
assert!(
|
|
NAMED.contains(&case) || matches!(case, Case::Shuffle(_)),
|
|
"{} runs only in the long seed scan; give it a case here",
|
|
case.name()
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn adding_and_removing_span_children_lands_where_growing_it_that_way_would() {
|
|
for case in ALL {
|
|
if matches!(case, Case::Shuffle(_)) {
|
|
for seed in SEEDS {
|
|
check(seed, depth(), case);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "as many seeds as it is asked for, rather than the ten the others check"]
|
|
fn a_long_run_of_seeds_agrees() {
|
|
let depth = depth();
|
|
let seeds = rig::seeds("IRIS_GENERATED_SEED", "IRIS_GENERATED_SEEDS", 100);
|
|
over_seeds(seeds, |seed| {
|
|
let grown = plan(seed, depth, &Edits::default());
|
|
for case in ALL {
|
|
check_plan(&grown, seed, depth, case);
|
|
}
|
|
});
|
|
}
|