pointer: a test for a track that shrinks to zero width mid-drag; the rect.w > 0.0 guard is pinned

Finding slider-zero-width-guard-killable. A move over a zero-wide track must leave the draft as the press wrote it
(0/0 and n/0 are not values); the rect.w >= 0.0 mutant now fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-29 05:40:58 +01:00
commit 0f8fa3e341

View file

@ -981,6 +981,30 @@ fn a_slider_snaps_from_its_own_minimum_and_follows_its_own_track() {
}
}
#[test]
fn a_track_that_shrinks_to_nothing_mid_drag_leaves_the_draft_as_it_was() {
for mode in MODES {
let mut rig = Rig::new(MemState::new(), &controls_surface(), mode);
let track = rig.rect("level");
let value = |v: f64| Some(InputValue::Number(NumberValue { value: v }));
rig.send(down((track.x + 0.5 * track.w, track.y + 0.5)));
assert_eq!(rig.draft("level"), value(50.0), "{mode:?}");
// The surface shrinks under the pointer: the slider's rect is now zero wide.
for placed in rig.rendered.placed.iter_mut().filter(|placed| placed.id.as_str() == "level") {
placed.rect.w = 0.0;
}
// At the track's left edge (0 over 0) and past it (n over 0): neither is a value.
for x in [track.x, track.x + 10.0] {
rig.send(mv((x, track.y + 0.5)));
assert_eq!(rig.draft("level"), value(50.0), "{mode:?}: a move over a zero-width track at {x}");
}
rig.send(up((track.x, track.y)));
let minted = rig.minted();
assert_eq!(minted.len(), 1, "{mode:?}");
assert_eq!(minted[0].captured[0].value, InputValue::Number(NumberValue { value: 50.0 }), "{mode:?}");
}
}
#[test]
fn a_slider_with_no_range_or_a_step_of_zero_is_handled_by_what_it_declares() {
for mode in MODES {