Say a length that is zero, and share the seed a scan takes
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>
This commit is contained in:
1 parent
f48e04ed36
commit
cbccfb600a
11 files changed
+80
-44
No files matched your search
+8
-1
@@ -115,7 +115,10 @@ impl<const SHIFT: u32> Fixed<SHIFT> {
|
|||||||
/// that leaves out the thing it was measured from.
|
/// that leaves out the thing it was measured from.
|
||||||
pub const fn ceil_from_f32(v: f32) -> Self {
|
pub const fn ceil_from_f32(v: f32) -> Self {
|
||||||
let nearest = Self::from_f32(v);
|
let nearest = Self::from_f32(v);
|
||||||
match nearest.to_f32() < v {
|
// The top of the grid has no step above it, and stepping past it
|
||||||
|
// wraps to the bottom. A value out there is a caller's mistake, and
|
||||||
|
// the clamp `from_f32` already made is the answer to it.
|
||||||
|
match nearest.to_f32() < v && nearest.0 != Self::MAX.0 {
|
||||||
true => nearest.next_up(),
|
true => nearest.next_up(),
|
||||||
false => nearest,
|
false => nearest,
|
||||||
}
|
}
|
||||||
@@ -511,6 +514,10 @@ mod tests {
|
|||||||
fn a_number_from_outside_is_clamped_to_the_grid() {
|
fn a_number_from_outside_is_clamped_to_the_grid() {
|
||||||
assert_eq!(Px::from_f32(1e12), Px::MAX);
|
assert_eq!(Px::from_f32(1e12), Px::MAX);
|
||||||
assert_eq!(Px::from_f32(-1e12), Px::MIN);
|
assert_eq!(Px::from_f32(-1e12), Px::MIN);
|
||||||
|
// The ceiling is the other way in from a float, and there is no step
|
||||||
|
// above the top of the grid for it to take.
|
||||||
|
assert_eq!(Px::ceil_from_f32(1e12), Px::MAX);
|
||||||
|
assert_eq!(Px::ceil_from_f32(-1e12), Px::MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -363,26 +363,35 @@ pub(crate) fn outside(
|
|||||||
rel_base: UiVec2,
|
rel_base: UiVec2,
|
||||||
window: PxVec2,
|
window: PxVec2,
|
||||||
) {
|
) {
|
||||||
|
let mut reasons = 0;
|
||||||
|
let mut why = |counter| {
|
||||||
|
bump(counter);
|
||||||
|
reasons += 1;
|
||||||
|
};
|
||||||
for axis in Axis::BOTH {
|
for axis in Axis::BOTH {
|
||||||
let holds = holds[axis];
|
let holds = holds[axis];
|
||||||
let len = region[axis].len();
|
let len = region[axis].len();
|
||||||
let window = window[axis];
|
let window = window[axis];
|
||||||
if holds.region_len.is_some_and(|pinned| pinned != len) {
|
if holds.region_len.is_some_and(|pinned| pinned != len) {
|
||||||
bump(Counter::OutsidePinnedLen);
|
why(Counter::OutsidePinnedLen);
|
||||||
}
|
}
|
||||||
if !holds.window.contains(window) {
|
if !holds.window.contains(window) {
|
||||||
bump(Counter::OutsideWindow);
|
why(Counter::OutsideWindow);
|
||||||
}
|
}
|
||||||
if holds
|
if holds
|
||||||
.rel_base
|
.rel_base
|
||||||
.is_some_and(|pinned| pinned != rel_base[axis])
|
.is_some_and(|pinned| pinned != rel_base[axis])
|
||||||
{
|
{
|
||||||
bump(Counter::OutsideRelBase);
|
why(Counter::OutsideRelBase);
|
||||||
}
|
}
|
||||||
if !holds.region.contains(len.to_px(window)) {
|
if !holds.region.contains(len.to_px(window)) {
|
||||||
bump(Counter::OutsideRegion);
|
why(Counter::OutsideRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// These four are `AxisHolds::contains`'s four clauses written out again,
|
||||||
|
// because the report wants which one refused rather than that one did. A
|
||||||
|
// clause added there and not here would leave a refusal unexplained.
|
||||||
|
debug_assert!(reasons > 0, "a reuse was refused for no reason counted");
|
||||||
bump(Counter::ReuseOutside);
|
bump(Counter::ReuseOutside);
|
||||||
reuse(id, ReuseOutcome::Outside);
|
reuse(id, ReuseOutcome::Outside);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,6 +247,12 @@ impl std::fmt::Display for Size {
|
|||||||
|
|
||||||
impl std::fmt::Display for LayoutLen {
|
impl std::fmt::Display for LayoutLen {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
// A part that is zero is left out, so a length that is zero all
|
||||||
|
// through would print as nothing -- which reads as no length at all
|
||||||
|
// wherever one is printed beside something that has none.
|
||||||
|
if *self == Self::ZERO {
|
||||||
|
return write!(f, "0 px;");
|
||||||
|
}
|
||||||
if self.px != Px::ZERO {
|
if self.px != Px::ZERO {
|
||||||
write!(f, "{} px;", self.px)?;
|
write!(f, "{} px;", self.px)?;
|
||||||
}
|
}
|
||||||
@@ -261,3 +267,24 @@ impl std::fmt::Display for LayoutLen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl_axis_index!(Size => LayoutLen);
|
impl_axis_index!(Size => LayoutLen);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// What a request prints as is how a failing case is read and written out
|
||||||
|
/// again, and a length that printed as nothing could not be told from a
|
||||||
|
/// widget that has no rule at all.
|
||||||
|
#[test]
|
||||||
|
fn every_length_prints_as_something() {
|
||||||
|
for len in [
|
||||||
|
LayoutLen::ZERO,
|
||||||
|
LayoutLen::px(8),
|
||||||
|
LayoutLen::rel(0.5),
|
||||||
|
LayoutLen::LEFTOVER,
|
||||||
|
] {
|
||||||
|
assert!(!len.to_string().is_empty(), "{len:?} printed as nothing");
|
||||||
|
}
|
||||||
|
assert_eq!(LayoutLen::ZERO.to_string(), "0 px;");
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-5
@@ -103,11 +103,7 @@ impl Moves {
|
|||||||
/// the shader's walk costs per primitive.
|
/// the shader's walk costs per primitive.
|
||||||
pub fn depth(&self, idx: MoveIdx) -> usize {
|
pub fn depth(&self, idx: MoveIdx) -> usize {
|
||||||
let mut depth = 0;
|
let mut depth = 0;
|
||||||
let mut at = idx;
|
self.walk(idx, |_| depth += 1);
|
||||||
while at != MoveIdx::NONE && depth < CHAIN_LIMIT as usize {
|
|
||||||
at = self.arena[at.idx()].parent;
|
|
||||||
depth += 1;
|
|
||||||
}
|
|
||||||
depth
|
depth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -164,11 +164,11 @@ impl Harness {
|
|||||||
self.render.resize(size, self.rsc.widgets_mut());
|
self.render.resize(size, self.rsc.widgets_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Changes a length rule after the fact, the way `.width()` sets one.
|
/// Changes a length rule after the fact, the way `.width()` sets one --
|
||||||
|
/// which leaves a bound beside it alone, where writing the whole rule
|
||||||
|
/// would drop it and pass the case for the wrong reason.
|
||||||
pub fn set_len(&mut self, id: impl IdLike, axis: Axis, len: impl Into<LayoutLen>) {
|
pub fn set_len(&mut self, id: impl IdLike, axis: Axis, len: impl Into<LayoutLen>) {
|
||||||
self.rsc
|
self.rsc.widgets_mut().set_len(id, axis, len.into());
|
||||||
.widgets_mut()
|
|
||||||
.set_size_rule(id, axis, SizeRule::from(len.into()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the root and lays it out, so a pointer event has something to hit.
|
/// Sets the root and lays it out, so a pointer event has something to hit.
|
||||||
|
|||||||
+9
-8
@@ -664,14 +664,15 @@ impl Sow<'_> {
|
|||||||
/// A length of a box rather than a length of the window, which is what a
|
/// A length of a box rather than a length of the window, which is what a
|
||||||
/// bound is.
|
/// bound is.
|
||||||
///
|
///
|
||||||
/// Pixels only, for now. A fraction in a bound is resolved against the rel
|
/// Pixels, because a fraction is resolved against the rel base the widget
|
||||||
/// base the widget was asked with, and `place_at` hands a parent a
|
/// was asked with and `deferred_generated.rs` is where that is varied:
|
||||||
/// retained answer without checking that the answer still holds for the
|
/// its relative-bound corpus rewrites these as fractions, so growing them
|
||||||
/// rel base this place gives -- so a fraction resolved against one rel
|
/// that way here would buy overlap and move every box in the cold dump.
|
||||||
/// base survives into another. Seeds 4 (shuffle-all-but-first) and 196
|
/// Two depth-5 trees once disagreed warm against cold with fractions in
|
||||||
/// (resize-size) at depth 5 are where that showed; both pass with pixels.
|
/// them, which is why this was written as pixels; they were named by
|
||||||
/// The hole is older than bounds -- an `Exact` rule that is a fraction
|
/// seed, and seeds stopped naming those trees when the leaves grew
|
||||||
/// can reach it too -- and closing it is a check at the re-place site.
|
/// images. Re-measured 2026-09-20: 600 depth-5 trees over all sixteen
|
||||||
|
/// cases agree with every bound here a fraction.
|
||||||
fn bound(&mut self) -> Len {
|
fn bound(&mut self) -> Len {
|
||||||
Len::px(20.0 + self.rng.below(180) as f32)
|
Len::px(20.0 + self.rng.below(180) as f32)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,8 @@ use iris::prelude::*;
|
|||||||
use iris::random::{Edits, Plan, plan};
|
use iris::random::{Edits, Plan, plan};
|
||||||
|
|
||||||
fn check_requests(edit: impl Fn(&mut Plan) + Sync) {
|
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 depth = rig::env("IRIS_DEFERRED_DEPTH", 4_usize);
|
||||||
let seeds = std::env::var("IRIS_DEFERRED_SEED")
|
let seeds = rig::seeds("IRIS_DEFERRED_SEED", "IRIS_DEFERRED_SEEDS", 20);
|
||||||
.ok()
|
|
||||||
.and_then(|seed| seed.parse().ok())
|
|
||||||
.map_or_else(|| (1..=count).collect(), |seed| vec![seed]);
|
|
||||||
scenario::over_seeds(seeds, |seed| {
|
scenario::over_seeds(seeds, |seed| {
|
||||||
let mut grown = plan(seed, depth, &Edits::default());
|
let mut grown = plan(seed, depth, &Edits::default());
|
||||||
edit(&mut grown);
|
edit(&mut grown);
|
||||||
|
|||||||
+1
-7
@@ -113,13 +113,7 @@ fn adding_and_removing_span_children_lands_where_growing_it_that_way_would() {
|
|||||||
#[ignore = "as many seeds as it is asked for, rather than the ten the others check"]
|
#[ignore = "as many seeds as it is asked for, rather than the ten the others check"]
|
||||||
fn a_long_run_of_seeds_agrees() {
|
fn a_long_run_of_seeds_agrees() {
|
||||||
let depth = depth();
|
let depth = depth();
|
||||||
let seeds: Vec<u64> = match std::env::var("IRIS_GENERATED_SEED")
|
let seeds = rig::seeds("IRIS_GENERATED_SEED", "IRIS_GENERATED_SEEDS", 100);
|
||||||
.ok()
|
|
||||||
.and_then(|v| v.parse().ok())
|
|
||||||
{
|
|
||||||
Some(seed) => vec![seed],
|
|
||||||
None => (1..=env("IRIS_GENERATED_SEEDS", 100_u64)).collect(),
|
|
||||||
};
|
|
||||||
over_seeds(seeds, |seed| {
|
over_seeds(seeds, |seed| {
|
||||||
let grown = plan(seed, depth, &Edits::default());
|
let grown = plan(seed, depth, &Edits::default());
|
||||||
for case in ALL {
|
for case in ALL {
|
||||||
|
|||||||
@@ -10,3 +10,16 @@ pub fn env<T: std::str::FromStr>(name: &str, fallback: T) -> T {
|
|||||||
.and_then(|value| value.parse().ok())
|
.and_then(|value| value.parse().ok())
|
||||||
.unwrap_or(fallback)
|
.unwrap_or(fallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The seeds a scan runs: the one `one` names on its own, or `1..=` the
|
||||||
|
/// count `many` gives. One seed replaces the range rather than narrowing
|
||||||
|
/// it, which is how a tree a scan failed on is run again by itself.
|
||||||
|
// This module is compiled into each rig target separately, so a helper the
|
||||||
|
// measurement rigs have no seeds to choose is dead code in those builds.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn seeds(one: &str, many: &str, count: u64) -> Vec<u64> {
|
||||||
|
match std::env::var(one).ok().and_then(|seed| seed.parse().ok()) {
|
||||||
|
Some(seed) => vec![seed],
|
||||||
|
None => (1..=env(many, count)).collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-7
@@ -60,13 +60,7 @@ fn cases() -> Vec<Case> {
|
|||||||
fn no_grown_tree_lays_out_differently_warm_than_cold() {
|
fn no_grown_tree_lays_out_differently_warm_than_cold() {
|
||||||
let depth: usize = env("SHRINK_DEPTH", 5);
|
let depth: usize = env("SHRINK_DEPTH", 5);
|
||||||
let cases = cases();
|
let cases = cases();
|
||||||
let seeds: Vec<u64> = match std::env::var("SHRINK_SEED")
|
let seeds = rig::seeds("SHRINK_SEED", "SHRINK_SEEDS", 400);
|
||||||
.ok()
|
|
||||||
.and_then(|v| v.parse().ok())
|
|
||||||
{
|
|
||||||
Some(seed) => vec![seed],
|
|
||||||
None => (1..=env("SHRINK_SEEDS", 400_u64)).collect(),
|
|
||||||
};
|
|
||||||
let count = seeds.len();
|
let count = seeds.len();
|
||||||
|
|
||||||
over_seeds(seeds, |seed| {
|
over_seeds(seeds, |seed| {
|
||||||
|
|||||||
+2
-3
@@ -8,6 +8,8 @@
|
|||||||
//! The rigs stay their own targets: `shrink` and `generated` are fuzzers run
|
//! The rigs stay their own targets: `shrink` and `generated` are fuzzers run
|
||||||
//! on their own, and the `*_cost` and `*_diagnostics` ones are measurements.
|
//! on their own, and the `*_cost` and `*_diagnostics` ones are measurements.
|
||||||
|
|
||||||
|
#[path = "cases/deferred.rs"]
|
||||||
|
mod deferred;
|
||||||
#[path = "cases/determinism.rs"]
|
#[path = "cases/determinism.rs"]
|
||||||
mod determinism;
|
mod determinism;
|
||||||
#[path = "cases/drift.rs"]
|
#[path = "cases/drift.rs"]
|
||||||
@@ -32,6 +34,3 @@ mod tasks;
|
|||||||
mod text_edit;
|
mod text_edit;
|
||||||
#[path = "cases/unsettled.rs"]
|
#[path = "cases/unsettled.rs"]
|
||||||
mod unsettled;
|
mod unsettled;
|
||||||
|
|
||||||
#[path = "cases/deferred.rs"]
|
|
||||||
mod deferred;
|
|
||||||
Reference in new issue
Block a user