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>
86 lines
2.8 KiB
Rust
86 lines
2.8 KiB
Rust
mod rig;
|
|
#[path = "scenario/mod.rs"]
|
|
mod scenario;
|
|
|
|
use iris::prelude::*;
|
|
use iris::random::{Edits, Plan, plan};
|
|
|
|
fn check_requests(edit: impl Fn(&mut Plan) + Sync) {
|
|
let depth = rig::env("IRIS_DEFERRED_DEPTH", 4_usize);
|
|
let seeds = rig::seeds("IRIS_DEFERRED_SEED", "IRIS_DEFERRED_SEEDS", 20);
|
|
scenario::over_seeds(seeds, |seed| {
|
|
let mut grown = plan(seed, depth, &Edits::default());
|
|
edit(&mut grown);
|
|
for case in scenario::ALL {
|
|
if let Some(how) = scenario::diverges(&grown, case, seed) {
|
|
panic!(
|
|
"request seed {seed} depth {depth} after {}: {how}",
|
|
case.name()
|
|
);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn deferred_requests_agree_warm_and_cold() {
|
|
check_requests(|grown| {
|
|
let mut index = 0;
|
|
grown.walk_mut(&mut |node| {
|
|
if let Some(rules) = &mut node.size {
|
|
for axis in Axis::BOTH {
|
|
index += 1;
|
|
rules[axis] = match index % 7 {
|
|
0 => leftover(1).clamp(20, 120).into(),
|
|
1 => leftover(1).min(rel(0.5)).into(),
|
|
2 => (leftover(1) + px(30)).min(leftover(2)).into(),
|
|
// Both sides an expression, the one shape that
|
|
// copies a request's nodes into another's.
|
|
3 => leftover(1).min(px(40)).max(leftover(2).min(px(70))).into(),
|
|
_ => rules[axis].clone(),
|
|
};
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn relative_intrinsic_bounds_agree_warm_and_cold() {
|
|
check_requests(|grown| {
|
|
grown.walk_mut(&mut |node| {
|
|
if let Some(rules) = &mut node.size {
|
|
for axis in Axis::BOTH {
|
|
let bound = &mut rules[axis].bound;
|
|
if bound.min.is_some() {
|
|
bound.min = Some(Len::rel(0.25));
|
|
}
|
|
if bound.max.is_some() {
|
|
bound.max = Some(Len::rel(0.75));
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn preferred_requests_with_independent_bounds_agree_warm_and_cold() {
|
|
check_requests(|grown| {
|
|
let mut index = 0;
|
|
grown.walk_mut(&mut |node| {
|
|
if let Some(rules) = &mut node.size {
|
|
for axis in Axis::BOTH {
|
|
index += 1;
|
|
rules[axis].request = Some(match index % 4 {
|
|
0 => leftover(1).into(),
|
|
1 => rel(0.5).into(),
|
|
2 => px(80).into(),
|
|
_ => (leftover(1) + px(30)).min(leftover(2)),
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|