Tests: the saw cut's halves named after their faces, listed in the kernel's order

cut_keeps_posts_joined_while_apart_in_one_body expected the reply's `bodies` as
["Case", "Case (1)"]. That list is the state's order, which is SMLib's lump order (the -x half
first); the names follow the pieces' faces (lineage::order_lumps, 08cf526fe): the piece whose
least face name sorts first keeps "Case". That is the +x half, whose least is `F1:+x`, before the
-x half's least, its piece of `F1:+y`. The test now checks the names as a set, that the +x half
(from x = 1) is "Case" and the -x half (from x = -30) "Case (1)", and each half's volume as
before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jyviko
2026-10-29 22:55:46 -04:00
committed by Irakli Kourtis
parent bf74dcbbe8
commit 8f914ddd2c
@@ -1060,8 +1060,15 @@ fn cut_keeps_posts_joined_while_apart_in_one_body() {
// A cut through the middle of the case still leaves two bodies, and says it made the second.
s.execute("solid.box", &json!({"length": 2, "width": 80, "height": 80, "center": [0, 0, 20], "operation": "new", "body_name": "Saw"})).unwrap();
let saw = s.execute("solid.combine", &json!({"target": "Case", "tools": ["Saw"], "operation": "cut"})).unwrap();
assert_eq!(saw["bodies"], json!(["Case", "Case (1)"]), "{saw}");
// `bodies` lists them in the kernel's order. The piece whose least face name sorts first keeps
// the name (`lineage::order_lumps`): the +x half, whose `F1:+x` sorts before the -x half's
// least, its piece of the case's `F1:+y`.
let mut bodies: Vec<&str> = saw["bodies"].as_array().unwrap().iter().filter_map(Value::as_str).collect();
bodies.sort_unstable();
assert_eq!(bodies, ["Case", "Case (1)"], "{saw}");
assert_eq!(saw["created_bodies"], json!(["Case (1)"]), "{saw}");
let low_x = |name: &str| s.model.state().body(name).unwrap().mesh().bounds().min.x;
assert!((low_x("Case") - 1.0).abs() < 1e-9 && (low_x("Case (1)") + 30.0).abs() < 1e-9);
let half = (60.0 - 2.0) / 2.0 * 40.0 * 10.0 + posts / 2.0;
for name in ["Case", "Case (1)"] {
assert!((volume(&s, name) - half).abs() < 1e-6 * half, "{name}: {} vs {half}", volume(&s, name));