Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Test (ignored until params reads unit-less length parameters in design units): a bare inch width stays 50.8 mm when the design goes metric

bherbruckfd4d38d31eb8
diff --git a/crates/engine/src/cmd/browser.rs b/crates/engine/src/cmd/browser.rs
index 86ab2922a0..d3591bdd89 100644
--- a/crates/engine/src/cmd/browser.rs
+++ b/crates/engine/src/cmd/browser.rs
@@ -441,6 +441,24 @@ mod tests {
assert_eq!(s.doc.units, "mm");
}
+ #[test]
+ #[ignore = "waits for unit-less parameters used as lengths to read in the design's units (solvecraft-params)"]
+ fn a_bare_width_keeps_its_inches_when_the_design_goes_metric() {
+ let mut s = Session::default();
+ run(&mut s, "document.units", json!({"units": "in"}));
+ run(&mut s, "parameters.add", json!({"name": "w", "expression": "2", "unit": ""}));
+ run(&mut s, "solid.box", json!({"length": 10, "width": "w", "height": 5}));
+ let width = |s: &mut Session| {
+ let b = &run(s, "inspect.measure", json!({}))["bodies"][0]["bbox"];
+ b["max"][1].as_f64().unwrap() - b["min"][1].as_f64().unwrap()
+ };
+ assert!((width(&mut s) - 50.8).abs() < 1e-6, "2 in an inch design");
+ let r = run(&mut s, "document.units", json!({"units": "mm"}));
+ assert!((width(&mut s) - 50.8).abs() < 1e-6, "still 50.8 mm: {r}");
+ assert_eq!(r["kept"], json!(["w"]));
+ assert_eq!(s.doc.param("w").map(|p| p.expr.as_str()), Some("2 in"));
+ }
+
#[test]
fn named_views_are_saved_renamed_and_deleted() {
let mut s = Session::default();