A copy added by raising a body pattern's count after a rename is numbered after the highest stored copy, so it no longer takes the number the rename freed. Un-ignores the #372 regression test and adds one for undo/redo and save/reopen. Fixes #372. Co-authored-by: jonaswre <jonas.wrede@beyondit.gmbh>
This commit is contained in:
1 parent
711e5508b5
commit
f9c19ade16
2 files changed
+41
-2
No files matched your search
@@ -2806,7 +2806,6 @@ fn a_pattern_repeats_a_fillet_on_the_edges_it_found() {
|
||||
|
||||
/// A copy added by raising the count after a rename takes the next number, not the freed one (#372).
|
||||
#[test]
|
||||
#[ignore = "fails until #372 is fixed"]
|
||||
fn raising_a_pattern_count_after_a_rename_numbers_the_new_copy_after_the_others() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 10, "operation": "new_body", "body_name": "X"}));
|
||||
@@ -2966,3 +2965,24 @@ fn draft_on_a_cylinder_side_makes_a_frustum() {
|
||||
let expect = PI * h / 3.0 * (big * big + big * small + small * small);
|
||||
assert!(rel(volume(&mut s), expect) < 1e-3, "{} vs {expect}", volume(&mut s));
|
||||
}
|
||||
|
||||
/// The copies added after a rename keep their numbers through undo/redo, save/reopen and a
|
||||
/// further count change; lowering the count drops the last copies (#372).
|
||||
#[test]
|
||||
fn pattern_copies_added_after_a_rename_keep_their_numbers() {
|
||||
let mut s = Session::default();
|
||||
let names = |s: &Session| -> Vec<String> { s.model.state().bodies.iter().map(|b| b.name.clone()).collect() };
|
||||
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 10, "operation": "new_body", "body_name": "X"}));
|
||||
run(&mut s, "solid.pattern.rectangular", json!({"bodies": ["X"], "dir1": [1, 0, 0], "count1": 3, "spacing1": 20, "name": "Pat"}));
|
||||
run(&mut s, "body.rename", json!({"body": "X (2)", "name": "Second"}));
|
||||
run(&mut s, "timeline.edit", json!({"feature": "Pat", "set": {"pattern": {"count1": "5"}}}));
|
||||
assert_eq!(names(&s), ["X", "Second", "X (3)", "X (4)", "X (5)"]);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_eq!(names(&s), ["X", "Second", "X (3)"]);
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_eq!(names(&s), ["X", "Second", "X (3)", "X (4)", "X (5)"]);
|
||||
let reopened = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
|
||||
assert_eq!(names(&reopened), ["X", "Second", "X (3)", "X (4)", "X (5)"]);
|
||||
run(&mut s, "timeline.edit", json!({"feature": "Pat", "set": {"pattern": {"count1": "2"}}}));
|
||||
assert_eq!(names(&s), ["X", "Second"]);
|
||||
}
|
||||
Reference in new issue
Block a user