Files
cadcraft/crates/engine/tests/it/scale_zero_factor.rs
T
Christopher Gay 2c690e5da0 SCALE: a factor point on the base point re-prompts instead of ending the command (fixes #3475)
At the Specify scale factor prompt, a picked point at the base point gives a
factor of zero. The command then cleared the selection and ended without
scaling anything or saying why. It now answers "Requires a positive number."
and stays at the prompt, keeping the selection and base point, as typed
factors and the Reference option already do. Non-finite factors are rejected
the same way.
2026-11-26 23:09:03 -06:00

27 lines
956 B
Rust

//! SCALE: a factor point on the base point is rejected and the prompt stays (#3475).
use cadcraft_engine::Session;
use cadcraft_engine::doc::EntityKind;
fn length(s: &Session) -> f64 {
s.doc().unwrap().model.iter().find_map(|e| if let EntityKind::Line(l) = &e.kind { Some(l.a.xy().dist(l.b.xy())) } else { None }).unwrap()
}
#[test]
fn scale_factor_point_on_base_point_keeps_the_prompt() {
let mut s = Session::new();
s.cmdline("LINE 0,0 10,0").unwrap();
s.cmdline("").unwrap();
s.cmdline("SCALE").unwrap();
s.cmdline("ALL").unwrap();
s.cmdline("").unwrap();
s.cmdline("0,0").unwrap();
let before = length(&s);
let _ = s.cmdline("0,0");
assert!(s.running.is_some(), "the command ended: {:?}", s.log);
assert_eq!(length(&s), before);
assert!(!s.selection().is_empty(), "the selection was cleared");
s.cmdline("0,3").unwrap();
assert!(length(&s) > before, "line not scaled: {}", length(&s));
}