Files
iris/tests/deferred_generated.rs
T
iris-aiandClaude Opus 5 f48e04ed36 Cover joining two expressions, and print a request one way
Four findings over 05e6ced, which no earlier round reviewed.

`SizeRequest::join` grafts the other side's nodes into this side's arena,
which happens only when both sides are expressions -- nothing in the suite
did that, so the whole thing passed with a `panic!` in that arm. It is
where a missed renumbering would be silent, since an operand copied
without remapping still names a node that exists. A fixture at two window
widths with absolute geometry covers it now, and the deferred corpus puts
an expression on both sides of one arm; both were checked to reach it by
instrumenting again. The path was already right.

`SizeRequest` grew a `Display` because a derived `Debug` of an arena is
not a tree anyone can write out again, and `describe` moved onto it -- but
`Debug` stayed derived, so the `assert_eq!`s in `cases/deferred.rs`, the
only place a request is compared, still printed the arena on failure.
`Debug` forwards to `Display`.

`Nodes::linear` asked nothing of the arena beside it: it is `Operand`'s
question, the way `RequestedLen::linear` is `RequestedLen`'s.

`describe`'s `|r| format!("{r}")` shadowed the `r: &SizeRule` four lines
above it.

Format, workspace clippy under -D warnings with and without
layout-diagnostics, 207 ordinary and 211 diagnostic tests, the cold dump
byte-identical to 05e6ced across all 34,986 boxes, and 400 depth-5 trees
in each of the three deferred corpora in 200.95s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 21:33:54 -04:00

90 lines
2.9 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 count = rig::env("IRIS_DEFERRED_SEEDS", 20_u64);
let depth = rig::env("IRIS_DEFERRED_DEPTH", 4_usize);
let seeds = std::env::var("IRIS_DEFERRED_SEED")
.ok()
.and_then(|seed| seed.parse().ok())
.map_or_else(|| (1..=count).collect(), |seed| vec![seed]);
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)),
});
}
}
});
});
}