Simplify text diff and hierarchy reports
Use signed cell rows and keep whole-cell contents out of the text diff. Group reference changes, fold redundant terminal edges into the cell list, and inline one-off layer names. Count identical unmatched objects while retaining occurrence-based display limits.
This commit is contained in:
parent
9d5fe27516
commit
ed1e0595bc
1 changed files with 775 additions and 226 deletions
361
tests/review.rs
361
tests/review.rs
|
|
@ -513,11 +513,11 @@ fn shared_hierarchy_reports_ancestors_and_marks_repeated_definitions() {
|
|||
diff.hierarchy(false, 8),
|
||||
concat!(
|
||||
"Hierarchy\n",
|
||||
"\"CHIP\" [affected]\n",
|
||||
" \"left\" x1 [affected]\n",
|
||||
" \"leaf\" x2 [changed]\n",
|
||||
" \"right\" x1 [affected]\n",
|
||||
" \"leaf\" x3 [changed] [shown above]\n",
|
||||
"CHIP [affected]\n",
|
||||
" left x1 [affected]\n",
|
||||
" * leaf x2\n",
|
||||
" right x1 [affected]\n",
|
||||
" * leaf x3 [shown above]\n",
|
||||
)
|
||||
);
|
||||
let graph = diff.hierarchy(true, 8);
|
||||
|
|
@ -525,8 +525,12 @@ fn shared_hierarchy_reports_ancestors_and_marks_repeated_definitions() {
|
|||
assert!(graph.contains("x2"));
|
||||
assert!(graph.contains("x3"));
|
||||
let limited = diff.hierarchy(false, 1);
|
||||
assert!(!limited.contains("\"leaf\""));
|
||||
assert!(!limited.contains("leaf"));
|
||||
assert!(limited.contains("children omitted"));
|
||||
assert_eq!(
|
||||
diff.hierarchy(false, 0),
|
||||
"Hierarchy\nCHIP [affected] [children omitted]\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -540,9 +544,9 @@ fn reference_changes_keep_unchanged_targets_and_old_edges_visible() {
|
|||
let diff = Comparison::between(&old, &new);
|
||||
let tree = diff.hierarchy(false, 8);
|
||||
let edge = if pair.name == "array count" {
|
||||
" \"leaf\" x2 -> x3\n"
|
||||
" leaf x2 -> x3\n"
|
||||
} else {
|
||||
" \"leaf\" x1 [reference changed]\n"
|
||||
" leaf x1 [reference changed]\n"
|
||||
};
|
||||
assert!(tree.ends_with(edge), "{tree}");
|
||||
}
|
||||
|
|
@ -554,8 +558,8 @@ fn reference_changes_keep_unchanged_targets_and_old_edges_visible() {
|
|||
let a = Document::parse(&a).unwrap();
|
||||
let b = Document::parse(&b).unwrap();
|
||||
for (old, new, edge) in [
|
||||
(&a, &b, " \"leaf\" x1 -> x0 [removed]\n"),
|
||||
(&b, &a, " \"leaf\" x0 -> x1 [added]\n"),
|
||||
(&a, &b, " - leaf x1 -> x0\n"),
|
||||
(&b, &a, " + leaf x0 -> x1\n"),
|
||||
] {
|
||||
let tree = Comparison::between(old, new).hierarchy(false, 8);
|
||||
assert!(tree.ends_with(edge), "{tree}");
|
||||
|
|
@ -778,6 +782,34 @@ fn cli_uses_documented_exit_codes_and_accepts_paths_with_spaces() {
|
|||
.unwrap()
|
||||
.starts_with("flowchart TD")
|
||||
);
|
||||
let with_reference = |x| layout(&[("CHIP", vec![reference("leaf", x, 1)]), ("leaf", vec![])]);
|
||||
fs::write(&old, with_reference(0)).unwrap();
|
||||
fs::write(&new, with_reference(5)).unwrap();
|
||||
let moved = command()
|
||||
.arg("diff")
|
||||
.arg(&old)
|
||||
.arg(&new)
|
||||
.args(["--hierarchy", "ascii"])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(moved.status.code(), Some(1));
|
||||
assert_eq!(
|
||||
moved.stdout,
|
||||
b"Different\nCells:\n* CHIP\n ~ reference \"leaf\" moved by (5, 0) dbu\n"
|
||||
);
|
||||
let scoped = command()
|
||||
.arg("diff")
|
||||
.arg(&old)
|
||||
.arg(&new)
|
||||
.args(["--hierarchy", "ascii", "--cell", "CHIP"])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(scoped.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8(scoped.stdout)
|
||||
.unwrap()
|
||||
.ends_with("Hierarchy\n* CHIP\n leaf x1 [reference changed] [outside scope]\n")
|
||||
);
|
||||
fs::write(&new, b"invalid").unwrap();
|
||||
assert_eq!(
|
||||
command()
|
||||
|
|
@ -1139,7 +1171,7 @@ fn display_filters_never_change_equality_or_totals() {
|
|||
assert!(text.starts_with("Different · 1 cell modified\n"));
|
||||
assert!(text.contains("Display filter layer=42/0\n"));
|
||||
assert!(text.contains("Omitted · 2 object changes filtered out"));
|
||||
assert!(!text.contains("cell \"CHIP\""));
|
||||
assert!(!text.contains("Cells:\n"));
|
||||
assert_eq!(diff.outcome().exit_code(), 1);
|
||||
}
|
||||
|
||||
|
|
@ -1152,24 +1184,31 @@ fn text_hides_empty_headings_and_counts_filtered_and_limited_changes() {
|
|||
let a = layout(&[
|
||||
("changed", vec![square()]),
|
||||
("other", vec![square()]),
|
||||
("gone", vec![square(), triangle()]),
|
||||
(
|
||||
"gone",
|
||||
vec![square(), triangle(), reference("target", 0, 1)],
|
||||
),
|
||||
("header", vec![]),
|
||||
("target", vec![]),
|
||||
]);
|
||||
let b = layout(&[
|
||||
("changed", vec![triangle()]),
|
||||
("other", vec![triangle()]),
|
||||
("new", vec![square()]),
|
||||
("new", vec![square(), reference("target", 0, 1)]),
|
||||
("empty", vec![]),
|
||||
("header", vec![attributes]),
|
||||
("target", vec![]),
|
||||
]);
|
||||
let diff = Comparison::between(&Document::parse(&a).unwrap(), &Document::parse(&b).unwrap());
|
||||
let text = diff.text(0);
|
||||
assert!(text.starts_with("Different · 3 cells modified, 2 added, 1 removed\n"));
|
||||
assert!(text.contains("cell \"gone\" (removed, 2 objects)\n"));
|
||||
assert!(text.contains("cell \"new\" (added, 1 object)\n"));
|
||||
assert!(text.contains("cell \"empty\" (added, 0 objects)\n"));
|
||||
assert!(text.contains("cell \"header\" (attributes changed)\n"));
|
||||
assert!(!text.contains("cell \"changed\""));
|
||||
assert!(text.ends_with(concat!(
|
||||
"Cells:\n",
|
||||
"- gone\n",
|
||||
"+ empty\n",
|
||||
"+ new\n",
|
||||
"* header (attributes changed)\n",
|
||||
)));
|
||||
assert!(text.contains("Omitted · 4 object changes over the limit"));
|
||||
|
||||
let text = diff.text_filtered(
|
||||
|
|
@ -1184,9 +1223,29 @@ fn text_hides_empty_headings_and_counts_filtered_and_limited_changes() {
|
|||
"Omitted · 2 object changes filtered out · 2 object changes over the limit",
|
||||
" · 4 cell-level changes filtered out\n",
|
||||
)));
|
||||
assert!(!text.contains("cell \"changed\""));
|
||||
assert!(!text.contains("cell \"other\""));
|
||||
assert!(!text.contains("cell \"new\""));
|
||||
assert!(!text.contains("Cells:\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cell_list_quotes_names_with_whitespace() {
|
||||
let old = layout(&[("old name", vec![]), ("same\nname", vec![square()])]);
|
||||
let new = layout(&[("new_name", vec![]), ("same\nname", vec![triangle()])]);
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&old).unwrap(),
|
||||
&Document::parse(&new).unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
diff.text(100),
|
||||
concat!(
|
||||
"Different\n",
|
||||
"Cells:\n",
|
||||
"- \"old name\"\n",
|
||||
"+ new_name\n",
|
||||
"* \"same\\nname\"\n",
|
||||
" 1/0: 1 polygon changed\n",
|
||||
)
|
||||
);
|
||||
assert!(diff.hierarchy(false, 8).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1214,25 +1273,16 @@ fn reference_summaries_group_repeated_targets_and_keep_full_placements_in_dumps(
|
|||
let with_chip = Document::parse(&with_chip).unwrap();
|
||||
let existing_chip = Document::parse(&existing_chip).unwrap();
|
||||
|
||||
for (old, new, action, sign) in [
|
||||
(&empty, &with_chip, "added", "+"),
|
||||
(&with_chip, &empty, "removed", "-"),
|
||||
] {
|
||||
for (old, new, sign) in [(&empty, &with_chip, '+'), (&with_chip, &empty, '-')] {
|
||||
let diff = Comparison::between(old, new);
|
||||
let text_diff = TextComparison::between(old, new);
|
||||
let text = diff.text(100);
|
||||
assert!(text.contains(&format!("cell \"CHIP\" ({action}, 6 objects)\n")));
|
||||
assert!(text.contains(&format!(
|
||||
" {sign} 2 references, 1 array reference to \"leaf\" (4 placements)\n"
|
||||
)));
|
||||
assert!(text.contains(&format!(" {sign} 1 reference to \"other\"\n")));
|
||||
assert!(!text.contains("xy="));
|
||||
assert!(text.ends_with(&format!("Cells:\n{sign} CHIP\n")));
|
||||
assert!(!text.contains("\n "));
|
||||
assert!(!text.contains("1/0"));
|
||||
assert!(!text.contains("2/0"));
|
||||
assert!(!text.contains("Omitted"));
|
||||
let limited = diff.text(2);
|
||||
assert!(limited.contains(&format!(" {sign} 2 references to \"leaf\"\n")));
|
||||
assert!(limited.contains("Omitted · 2 object changes over the limit"));
|
||||
assert_eq!(diff.text(0), text);
|
||||
assert_eq!(text_diff.outcome(), diff.outcome());
|
||||
for mermaid in [false, true] {
|
||||
assert_eq!(text_diff.hierarchy(mermaid, 8), diff.hierarchy(mermaid, 8));
|
||||
|
|
@ -1263,7 +1313,7 @@ fn reference_summaries_group_repeated_targets_and_keep_full_placements_in_dumps(
|
|||
] {
|
||||
let text = Comparison::between(old, new).text(100);
|
||||
assert!(text.contains(&format!(
|
||||
" {sign} 2 references, 1 array reference to \"leaf\" (4 placements)\n"
|
||||
" {sign} 2 refs, 1 array ref to leaf (4 placements)\n"
|
||||
)));
|
||||
assert!(!text.contains("\"leaf\" xy="));
|
||||
assert!(text.contains(&format!(" {sign} reference \"other\" xy=(10, 0)\n")));
|
||||
|
|
@ -1273,6 +1323,139 @@ fn reference_summaries_group_repeated_targets_and_keep_full_placements_in_dumps(
|
|||
assert!(dump.contains(" array reference \"leaf\" (2 × 1) xy=[(2, 0), (102, 0), (2, 0)]\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reference_summaries_combine_visible_changes_to_a_target() {
|
||||
let make_layout = |positions: std::ops::Range<i32>, moving_x| {
|
||||
let mut refs: Vec<_> = positions
|
||||
.chain(20..27)
|
||||
.map(|x| reference("leaf", x, 1))
|
||||
.collect();
|
||||
refs.push(reference("moving", moving_x, 1));
|
||||
refs.push(reference("moving", 99, 1));
|
||||
layout(&[("CHIP", refs), ("leaf", vec![]), ("moving", vec![])])
|
||||
};
|
||||
let old = make_layout(0..3, 0);
|
||||
let new = make_layout(10..16, 5);
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&old).unwrap(),
|
||||
&Document::parse(&new).unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
diff.text(100),
|
||||
concat!(
|
||||
"Different\nCells:\n* CHIP\n",
|
||||
" ~ reference \"moving\" moved by (5, 0) dbu · 2 total placements\n",
|
||||
" leaf · -3 refs, +6 refs · placements 10 -> 13\n",
|
||||
)
|
||||
);
|
||||
let ascii =
|
||||
|max, show: &DisplayFilter| diff.render_text_with_ascii_hierarchy(max, show, true, 8);
|
||||
assert_eq!(ascii(100, &Default::default()), diff.text(100));
|
||||
assert!(diff.text(5).ends_with(" - 3 refs to leaf\n"));
|
||||
let limited = diff.text(6);
|
||||
assert!(
|
||||
limited.starts_with(
|
||||
"Different · 1 cell modified\nOmitted · 5 object changes over the limit\n"
|
||||
)
|
||||
);
|
||||
assert!(limited.ends_with(" leaf · -3 refs, +1 ref\n"));
|
||||
let limited_ascii = ascii(6, &Default::default());
|
||||
assert!(limited_ascii.starts_with(&limited));
|
||||
assert!(limited_ascii.ends_with("Hierarchy\n* CHIP\n leaf x10 -> x13\n"));
|
||||
|
||||
let filtered = ascii(
|
||||
100,
|
||||
&DisplayFilter {
|
||||
cell: None,
|
||||
layer: Some((1, 0)),
|
||||
},
|
||||
);
|
||||
assert!(filtered.contains("11 object changes filtered out"));
|
||||
assert!(filtered.ends_with(" leaf x10 -> x13\n moving x2 [reference changed]\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combined_ascii_hierarchy_preserves_paths_to_changed_and_shared_cells() {
|
||||
let make_layout = |x, shape| {
|
||||
layout(&[
|
||||
(
|
||||
"CHIP",
|
||||
vec![reference("left", 0, 1), reference("right", 0, 1)],
|
||||
),
|
||||
(
|
||||
"left",
|
||||
vec![
|
||||
reference("shared", x, 1),
|
||||
reference("changed", x, 1),
|
||||
reference("local", x, 1),
|
||||
],
|
||||
),
|
||||
("right", vec![reference("shared", x, 1)]),
|
||||
("shared", vec![]),
|
||||
("changed", vec![shape]),
|
||||
("local", vec![]),
|
||||
])
|
||||
};
|
||||
let old = make_layout(0, square());
|
||||
let new = make_layout(5, triangle());
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&old).unwrap(),
|
||||
&Document::parse(&new).unwrap(),
|
||||
);
|
||||
let text = diff.render_text_with_ascii_hierarchy(100, &Default::default(), true, 8);
|
||||
let (cells, hierarchy) = text.split_once("Hierarchy\n").unwrap();
|
||||
assert!(cells.contains("reference \"local\" moved by (5, 0) dbu"));
|
||||
assert_eq!(
|
||||
hierarchy,
|
||||
concat!(
|
||||
"CHIP [affected]\n",
|
||||
" * left x1\n",
|
||||
" * changed x1 [reference changed]\n",
|
||||
" shared x1 [reference changed]\n",
|
||||
" * right x1\n",
|
||||
" shared x1 [reference changed] [shown above]\n",
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combined_reference_summaries_keep_array_counts_and_placements() {
|
||||
let old = layout(&[
|
||||
(
|
||||
"CHIP",
|
||||
vec![
|
||||
reference("leaf", 0, 1),
|
||||
reference("leaf", 10, 2),
|
||||
reference("leaf", 20, 3),
|
||||
],
|
||||
),
|
||||
("leaf", vec![]),
|
||||
]);
|
||||
let new = layout(&[
|
||||
(
|
||||
"CHIP",
|
||||
vec![
|
||||
reference("leaf", 50, 1),
|
||||
reference("leaf", 60, 1),
|
||||
reference("leaf", 70, 2),
|
||||
reference("leaf", 80, 4),
|
||||
],
|
||||
),
|
||||
("leaf", vec![]),
|
||||
]);
|
||||
let diff = Comparison::between(
|
||||
&Document::parse(&old).unwrap(),
|
||||
&Document::parse(&new).unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
diff.text(100),
|
||||
concat!(
|
||||
"Different\nCells:\n* CHIP\n",
|
||||
" leaf · -1 ref, -2 array refs (6 placements), +2 refs, +2 array refs (8 placements)\n",
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn git_external_driver_handles_changes_additions_deletions_and_errors() {
|
||||
let directory = std::env::temp_dir().join(format!(
|
||||
|
|
@ -1340,7 +1523,7 @@ fn git_external_driver_handles_changes_additions_deletions_and_errors() {
|
|||
assert!(
|
||||
String::from_utf8(changed.stdout)
|
||||
.unwrap()
|
||||
.contains("Different · 1 cell modified\n")
|
||||
.contains("Different\nCells:\n* CHIP\n")
|
||||
);
|
||||
fs::write(&path, b"invalid").unwrap();
|
||||
let invalid = Command::new("git")
|
||||
|
|
@ -1372,15 +1555,17 @@ fn git_external_driver_handles_changes_additions_deletions_and_errors() {
|
|||
let result = git(&["diff", "--cached", "--", "added layout.gds"]);
|
||||
let text = String::from_utf8(result.stdout).unwrap();
|
||||
assert!(text.starts_with("layout \"added layout.gds\" added\nDifferent · 4 cells added\n"));
|
||||
assert!(text.contains("Cells:\n+ CHIP\n+ leaf\n+ left\n+ right\nHierarchy\n"));
|
||||
assert!(!text.contains("\nmode "));
|
||||
assert!(!text.contains("\nlibrary "));
|
||||
fs::remove_file(&path).unwrap();
|
||||
git(&["add", "-u"]);
|
||||
let result = git(&["diff", "--cached", "--", "chip layout.gds"]);
|
||||
let text = String::from_utf8(result.stdout).unwrap();
|
||||
assert!(text.starts_with("layout \"chip layout.gds\" deleted\nDifferent · 1 cell removed\n"));
|
||||
assert!(!text.contains("\nmode "));
|
||||
assert!(!text.contains("\nlibrary "));
|
||||
assert_eq!(
|
||||
text,
|
||||
"layout \"chip layout.gds\" deleted\nDifferent\nCells:\n- CHIP\n"
|
||||
);
|
||||
// Textconv is an alternative to the external driver, with a separate cache.
|
||||
git(&["commit", "-qm", "replace fixture"]);
|
||||
git(&["mv", "added layout.gds", "renamed layout.gds"]);
|
||||
|
|
@ -1390,7 +1575,7 @@ fn git_external_driver_handles_changes_additions_deletions_and_errors() {
|
|||
let result = git(&["diff", "--cached", "--find-renames"]);
|
||||
let text = String::from_utf8(result.stdout).unwrap();
|
||||
assert!(text.contains("renamed layout.gds"), "{text}");
|
||||
assert!(text.contains("Different · 1 cell modified\n"), "{text}");
|
||||
assert!(text.contains("Different\nCells:\n* leaf\n"), "{text}");
|
||||
git(&["commit", "-qm", "rename fixture"]);
|
||||
fs::write(directory.join(".gitattributes"), "*.gds diff=pheon-text\n").unwrap();
|
||||
fs::write(&renamed, shared(square())).unwrap();
|
||||
|
|
@ -1526,8 +1711,8 @@ fn polygon_diff_groups_shapes_by_layer_across_dimensions() {
|
|||
assert_eq!(
|
||||
diff.text(100),
|
||||
concat!(
|
||||
"Different · 1 cell modified\n",
|
||||
"cell \"CHIP\"\n",
|
||||
"Different\n",
|
||||
"Cells:\n* CHIP\n",
|
||||
" 1/0: 2 rectangles, 1 polygon changed\n",
|
||||
" 2/0: 1 polygon changed\n",
|
||||
)
|
||||
|
|
@ -1580,7 +1765,11 @@ fn unmatched_paths_summarize_coordinates_that_would_wrap() {
|
|||
" {sign} 1/0: path · width {width} · 5 vertices · bounds (0, -5) to (13, 9) dbu\n"
|
||||
)));
|
||||
}
|
||||
assert_eq!(text.lines().count(), 5, "{text}");
|
||||
assert_eq!(
|
||||
text.lines().filter(|line| line.starts_with(" ")).count(),
|
||||
3,
|
||||
"{text}"
|
||||
);
|
||||
assert!(text.contains("xy=[(0, 0), (4, 0), (4, -5), (13, -5)]"));
|
||||
}
|
||||
assert!(paths.canonical_dump().contains("\n (13, 9)]"));
|
||||
|
|
@ -1596,6 +1785,41 @@ fn unmatched_paths_summarize_coordinates_that_would_wrap() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeated_unmatched_rows_group_only_identical_objects_within_the_limit() {
|
||||
let points = [[0, 0], [4, 0], [4, -5], [13, -5], [13, 9]];
|
||||
let mut other_points = points;
|
||||
other_points[1][0] = 5;
|
||||
let named_paths = |mut paths: Vec<Vec<u8>>| {
|
||||
paths.extend([label((900, 7), LAYER_SENTINEL), label((900, 7), "1:0:WG")]);
|
||||
layout(&[("CHIP", paths)])
|
||||
};
|
||||
let empty = named_paths(vec![]);
|
||||
let paths = named_paths(vec![
|
||||
path(None, &points),
|
||||
path(None, &other_points),
|
||||
path(None, &points),
|
||||
]);
|
||||
let empty = Document::parse(&empty).unwrap();
|
||||
let paths = Document::parse(&paths).unwrap();
|
||||
for (old, new, sign) in [(&empty, &paths, "+"), (&paths, &empty, "-")] {
|
||||
let diff = Comparison::between(old, new);
|
||||
let details = "path · width absent · 5 vertices · bounds (0, -5) to (13, 9) dbu";
|
||||
let full = diff.text(3);
|
||||
assert!(full.contains("1/0: name \"WG\"\nCells:\n"));
|
||||
assert!(full.ends_with(&format!(
|
||||
" {sign} 2× 1/0: {details}\n {sign} 1/0: {details}\n"
|
||||
)));
|
||||
assert!(
|
||||
diff.text(2)
|
||||
.ends_with(&format!(" {sign} 2× 1/0 (WG): {details}\n"))
|
||||
);
|
||||
let limited = diff.text(1);
|
||||
assert!(limited.contains("2 object changes over the limit"));
|
||||
assert!(limited.ends_with(&format!(" {sign} 1/0 (WG): {details}\n")));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn label_replacements_show_only_changed_fields() {
|
||||
let a = layout(&[("CHIP", vec![label((2, 0), "old")])]);
|
||||
|
|
@ -1603,29 +1827,50 @@ fn label_replacements_show_only_changed_fields() {
|
|||
let diff = Comparison::between(&Document::parse(&a).unwrap(), &Document::parse(&b).unwrap());
|
||||
assert_eq!(
|
||||
diff.text(100),
|
||||
"Different · 1 cell modified\ncell \"CHIP\"\n ~ 2/0: label text \"old\" -> \"new\"\n"
|
||||
"Different\nCells:\n* CHIP\n ~ 2/0: label text \"old\" -> \"new\"\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unchanged_layer_names_explain_geometry_changes_once() {
|
||||
let named = |geometry| {
|
||||
layout(&[(
|
||||
"CHIP",
|
||||
vec![
|
||||
geometry,
|
||||
label((900, 7), LAYER_SENTINEL),
|
||||
label((900, 7), "1:0:WG"),
|
||||
],
|
||||
)])
|
||||
let named = |geometry, text| {
|
||||
layout(&[
|
||||
(
|
||||
"CHIP",
|
||||
vec![
|
||||
geometry,
|
||||
label((900, 7), LAYER_SENTINEL),
|
||||
label((900, 7), "1:0:WG"),
|
||||
],
|
||||
),
|
||||
("leaf", vec![label((1, 0), text)]),
|
||||
])
|
||||
};
|
||||
let a = named(square());
|
||||
let b = named(triangle());
|
||||
let diff = Comparison::between(&Document::parse(&a).unwrap(), &Document::parse(&b).unwrap());
|
||||
let text = diff.text(100);
|
||||
assert_eq!(text.matches("1/0: name \"WG\"").count(), 1);
|
||||
let old = named(square(), "old");
|
||||
let a = Document::parse(&old).unwrap();
|
||||
let new = named(triangle(), "old");
|
||||
let diff = Comparison::between(&a, &Document::parse(&new).unwrap());
|
||||
assert_eq!(
|
||||
diff.text(100),
|
||||
"Different\nCells:\n* CHIP\n 1/0 (WG): 1 polygon changed\n"
|
||||
);
|
||||
assert!(diff.layer_names.is_empty());
|
||||
|
||||
let new = named(triangle(), "new");
|
||||
let diff = Comparison::between(&a, &Document::parse(&new).unwrap());
|
||||
let text = diff.text(100);
|
||||
assert!(text.contains("1/0: name \"WG\"\nCells:\n"));
|
||||
assert!(!text.contains("(WG)"));
|
||||
assert!(diff.text(2).ends_with(" 1/0 (WG): 1 polygon changed\n"));
|
||||
let show = DisplayFilter {
|
||||
cell: Some("leaf".into()),
|
||||
layer: None,
|
||||
};
|
||||
assert!(
|
||||
diff.text_filtered(100, &show)
|
||||
.ends_with(" ~ 1/0 (WG): label text \"old\" -> \"new\"\n")
|
||||
);
|
||||
|
||||
let names = corpus()
|
||||
.into_iter()
|
||||
.find(|case| case.name == "layer name only")
|
||||
|
|
|
|||
Loading…
Reference in a new issue