Show the displacement of a single shape move
This commit is contained in:
parent
28b7f10f6e
commit
4789638e22
1 changed files with 94 additions and 27 deletions
|
|
@ -1759,7 +1759,7 @@ fn replacement_explanations_are_unique_and_keep_full_evidence() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn polygon_diff_reports_moves_and_other_changes_without_individual_geometry() {
|
||||
fn polygon_diff_reports_single_displacements_and_groups_bulk_moves() {
|
||||
let before = layout(&[("CHIP", vec![with_property(square(), "old")])]);
|
||||
let before = Document::parse(&before).unwrap();
|
||||
for (shape, label) in [
|
||||
|
|
@ -1787,26 +1787,65 @@ fn polygon_diff_reports_moves_and_other_changes_without_individual_geometry() {
|
|||
assert!(!text.contains("xy="));
|
||||
}
|
||||
|
||||
let moved_triangle = polygon(&[[2, -1], [12, -1], [2, 9], [2, -1]]);
|
||||
let moved_square = polygon(&[[2, -1], [12, -1], [12, 9], [2, 9], [2, -1]]);
|
||||
let named_layout = |mut objects: Vec<Vec<u8>>| {
|
||||
objects.extend([label((900, 7), LAYER_SENTINEL), label((900, 7), "1:0:WG")]);
|
||||
layout(&[("CHIP", objects)])
|
||||
};
|
||||
for (shape, shifted, name) in [
|
||||
(triangle(), moved_triangle, "polygon"),
|
||||
(square(), moved_square.clone(), "rectangle"),
|
||||
(
|
||||
triangle(),
|
||||
polygon(&[[2, -1], [12, -1], [2, 9], [2, -1]]),
|
||||
"polygon",
|
||||
),
|
||||
(
|
||||
square(),
|
||||
polygon(&[[2, -1], [12, -1], [12, 9], [2, 9], [2, -1]]),
|
||||
"rectangle",
|
||||
ring(
|
||||
RTAG_BOX,
|
||||
RTAG_BOXTYPE,
|
||||
1,
|
||||
&[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]],
|
||||
),
|
||||
ring(
|
||||
RTAG_BOX,
|
||||
RTAG_BOXTYPE,
|
||||
1,
|
||||
&[[2, -1], [12, -1], [12, 9], [2, 9], [2, -1]],
|
||||
),
|
||||
"box",
|
||||
),
|
||||
] {
|
||||
let before = layout(&[("CHIP", vec![shape])]);
|
||||
let after = layout(&[("CHIP", vec![shifted])]);
|
||||
let before = named_layout(vec![shape]);
|
||||
let after = named_layout(vec![shifted]);
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&before).unwrap(),
|
||||
&Document::parse(&after).unwrap(),
|
||||
);
|
||||
assert!(diff.text(100).contains(&format!(" 1/0: 1 {name} moved\n")));
|
||||
assert!(
|
||||
diff.text(100)
|
||||
.contains(&format!(" 1/0 (WG): {name} moved by (2, -1) dbu\n"))
|
||||
);
|
||||
}
|
||||
|
||||
let before = named_layout(vec![square()]);
|
||||
let after = named_layout(vec![
|
||||
moved_square,
|
||||
ring(
|
||||
RTAG_BOX,
|
||||
RTAG_BOXTYPE,
|
||||
1,
|
||||
&[[20, 0], [30, 0], [30, 10], [20, 10], [20, 0]],
|
||||
),
|
||||
]);
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&before).unwrap(),
|
||||
&Document::parse(&after).unwrap(),
|
||||
);
|
||||
assert!(
|
||||
diff.text(100)
|
||||
.contains(" 1/0 (WG): 1 rectangle moved · 1 box added\n")
|
||||
);
|
||||
assert!(
|
||||
diff.text(2)
|
||||
.contains(" 1/0 (WG): rectangle moved by (2, -1) dbu\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue