Tighten a validity range to what the arithmetic needs
`Holds::through`'s allowance for the two routes to a length was four half steps either side, from a derivation that said each rounding now drops a whole step where it used to drop half of one. That overshot: three is the floor, two fires the `Holds` assertion in `draw_at` on eleven generated cases, and four was never measured as necessary. Tightening both ends did not move one of the rig's twenty-five work counters, so the extra half step was not buying any reuse either. It cannot go to zero. The range has to contain the box a drawing was made in, which the assertion checks, and it must not contain a box the drawing does not hold for, which the warm-against-cold oracle checks -- and those two only coincide where a length reached two ways is the same number. It is not, yet; composing in `i64` and narrowing once is the queued change that would make it so, and shrinking this allowance is how to tell whether that worked. Checked: fmt, clippy, 81 suite tests, 17 core unit tests, the release oracle at 100 seeds and at 1000 seeds of depth 6, all fifteen shrinker cases at 400 seeds of depth 5, and `tabs`, `view`, `minimal`, `text`, `random` and the tab replay byte-identical at 1920x1200 against `2bc6bdf`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bc6bdfc77
commit
38eba543f6
1 file changed
+24
-20
+24
-20
@@ -55,23 +55,26 @@ impl Holds {
|
|||||||
if rel == 0 {
|
if rel == 0 {
|
||||||
return Self::ANY;
|
return Self::ANY;
|
||||||
}
|
}
|
||||||
// In half steps. The box a length was composed down the chain from
|
// In half steps, and no more than the arithmetic needs: too wide a
|
||||||
// and the box the same length is measured against the window in are
|
// range admits reusing a drawing where it does not hold, and too
|
||||||
// two routes to one number, each rounding where the other does not,
|
// narrow a one leaves out the box a drawing was made in, which the
|
||||||
// and each rounding drops a whole step since `Fixed::mul` truncates:
|
// `Holds` assertion in `draw_at` catches. `ROUTES` is at that floor
|
||||||
// two steps either side. The multiply on the way in drops a step of
|
// -- two half steps fires it -- and tightening both ends moved not
|
||||||
// its own, and only downward, so it is one more step at the top and
|
// one of the rig's work counters, so the slack is not buying reuse.
|
||||||
// nothing at the bottom -- and the whole of a box has no multiply in
|
//
|
||||||
// it, however many pixels were added to it, since multiplying by one
|
// `ROUTES` covers a box composed down the chain against the same box
|
||||||
// is exact and taking the pixels off again is too. Allowing for it
|
// measured against the window: two routes to one number, each
|
||||||
// there anyway compounded, a step a level down a chain of widgets
|
// rounding where the other does not. `way_in` covers the multiply
|
||||||
// each taking the whole of its parent, which is the unsound
|
// this inverts, which drops a step and only ever downward, so it
|
||||||
// direction: a range wider than what a drawing holds for admits
|
// belongs at the top of the range alone -- and the whole of a box has
|
||||||
// reusing it where it does not hold.
|
// no multiply in it, however many pixels were added to it, since
|
||||||
|
// multiplying by one is exact and taking the pixels off again is too.
|
||||||
|
// Allowing for it there anyway compounded, a step a level down a
|
||||||
|
// chain of widgets each taking the whole of its parent.
|
||||||
//
|
//
|
||||||
// Shifted by half of what a `Rel` counts in, to divide by the
|
// Shifted by half of what a `Rel` counts in, to divide by the
|
||||||
// fraction: exact until the division takes it back to the grid.
|
// fraction: exact until the division takes it back to the grid.
|
||||||
const ROUTES: i64 = 4;
|
const ROUTES: i64 = 3;
|
||||||
let px = len.px.raw() as i64;
|
let px = len.px.raw() as i64;
|
||||||
let half_rel = REL_SHIFT - 1;
|
let half_rel = REL_SHIFT - 1;
|
||||||
let way_in = match rel == Rel::ONE.raw() as i64 {
|
let way_in = match rel == Rel::ONE.raw() as i64 {
|
||||||
@@ -136,19 +139,20 @@ mod tests {
|
|||||||
/// taken off it, brings no multiply of its own: only the two routes to
|
/// taken off it, brings no multiply of its own: only the two routes to
|
||||||
/// the same length are left to allow for, and not a rounding that did
|
/// the same length are left to allow for, and not a rounding that did
|
||||||
/// not happen. Widening for it as well grew the interval a level at a
|
/// not happen. Widening for it as well grew the interval a level at a
|
||||||
/// time down a chain of them.
|
/// time down a chain of them. Three half steps come back as one whole
|
||||||
|
/// one, since dividing by a whole box is dividing by one.
|
||||||
#[test]
|
#[test]
|
||||||
fn the_whole_of_a_box_widens_by_the_routes_alone() {
|
fn the_whole_of_a_box_widens_by_the_routes_alone() {
|
||||||
let at = Px::from_int(956);
|
let at = Px::from_int(956);
|
||||||
let two_steps = |len: Px| Holds {
|
let one_step = |len: Px| Holds {
|
||||||
lo: len - Px::from_raw(2),
|
lo: len - Px::STEP,
|
||||||
hi: len + Px::from_raw(2),
|
hi: len + Px::STEP,
|
||||||
};
|
};
|
||||||
assert_eq!(Holds::at(at).through(Len::FULL), two_steps(at));
|
assert_eq!(Holds::at(at).through(Len::FULL), one_step(at));
|
||||||
let less_eight = Len::from_parts(Rel::ONE, Px::from_int(-8));
|
let less_eight = Len::from_parts(Rel::ONE, Px::from_int(-8));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Holds::at(at).through(less_eight),
|
Holds::at(at).through(less_eight),
|
||||||
two_steps(at + Px::from_int(8))
|
one_step(at + Px::from_int(8))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user