A pattern or mirror of a suppressed feature has nothing to copy: its copies go with it and the pattern warns (the acceptance enclosure loses all four standoffs when Standoff is suppressed); scenario acceptance_pattern_of_suppressed_feature enabled
Fixes #42 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGw4gA5ZvKrU8MQP6sBgT
This commit is contained in:
1 parent
d1428ef27c
commit
72bc6fb010
4 files changed
+59
-7
No files matched your search
@@ -434,6 +434,8 @@ mod delete_face_tests;
|
||||
#[cfg(test)]
|
||||
mod extent_tests;
|
||||
#[cfg(test)]
|
||||
mod pattern_suppress_tests;
|
||||
#[cfg(test)]
|
||||
mod profile_refs_tests;
|
||||
#[cfg(test)]
|
||||
mod split_face_tests;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//! A pattern of a suppressed feature has nothing to copy (#42): its copies go too, and the
|
||||
//! pattern says so.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::Session;
|
||||
|
||||
fn run(s: &mut Session, id: &str, p: Value) -> Value {
|
||||
match s.execute(id, &p) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("{id} {p}: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn volume(s: &Session, body: &str) -> f64 {
|
||||
s.model.state().body(body).map(|b| solvecraft_kernel::measure(&b.body).unwrap().volume).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn suppressing_a_patterned_feature_removes_its_copies() {
|
||||
let mut s = Session::default();
|
||||
let script: Value = serde_json::from_str(include_str!("../../../examples/acceptance/sensor_enclosure.json")).unwrap();
|
||||
s.run_script(&script).unwrap();
|
||||
let full = volume(&s, "Case");
|
||||
run(&mut s, "timeline.suppress", json!({"feature": "Standoff", "suppressed": true}));
|
||||
let without = volume(&s, "Case");
|
||||
// All four standoffs go (each 116.8 mm³), not just the seed.
|
||||
assert!((full - without - 4.0 * 116.8).abs() < 2.0, "{full} → {without}");
|
||||
let pattern = s.doc.find_feature("RectangularPattern1").unwrap().id;
|
||||
let r = s.model.result(pattern).unwrap();
|
||||
assert!(r.error.is_none() && r.warning.as_deref().is_some_and(|w| w.contains("Standoff")), "{r:?}");
|
||||
// Back on: the four standoffs return.
|
||||
run(&mut s, "timeline.suppress", json!({"feature": "Standoff", "suppressed": false}));
|
||||
assert!((volume(&s, "Case") - full).abs() < 1e-6 * full);
|
||||
}
|
||||
Reference in new issue
Block a user