From 0f58784a1ba01428fbba272551b925d1f4c06307 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 30 Sep 2026 17:06:17 +0200 Subject: [PATCH] Require each path's leaves, cover and table steps from compilePath --- path_test.go | 13 ++++++------- table_test.go | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/path_test.go b/path_test.go index fde337b..9866f2f 100644 --- a/path_test.go +++ b/path_test.go @@ -9,8 +9,8 @@ import ( func TestPathCheckStopsAtAMissingSegment(t *testing.T) { n := compiled(t, `{"format":"{a}","a":{"format":"{b}","b":"leaf"}}`) - if leaves := pathLeaves(n, []string{"a", "b"}); len(leaves) != 1 { - t.Fatalf("pathLeaves(a.b) = %v, want the one leaf", leaves) + if leaves := compilePath(n, []string{"a", "b"}).leaves; len(leaves) != 1 { + t.Fatalf("compilePath(a.b).leaves = %v, want the one leaf", leaves) } w := &pathCheck{tail: []string{"a", "nope", "deeper"}} _, err := w.run(n) @@ -24,16 +24,15 @@ func TestPathCheckStopsAtAMissingSegment(t *testing.T) { func TestPathCheckChoiceConsumesNoSegment(t *testing.T) { n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`) - if leaves := pathLeaves(n, []string{"f"}); len(leaves) != 2 { - t.Fatalf("pathLeaves through a choice = %v, want both variants' f", leaves) + if leaves := compilePath(n, []string{"f"}).leaves; len(leaves) != 2 { + t.Fatalf("compilePath through a choice = %v, want both variants' f", leaves) } } func TestPathCoverStopsAtAChoice(t *testing.T) { n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`) - leaf, err := (&pathCover{into: map[node]bool{}}).walk(n, []string{"f"}) - if err != nil || leaf != n { - t.Fatalf("cover through a choice = %v, %v, want the choice itself", leaf, err) + if cover := compilePath(n, []string{"f"}).cover; cover != n { + t.Fatalf("cover through a choice = %v, want the choice itself", cover) } } diff --git a/table_test.go b/table_test.go index 1aca9ec..1fcdb36 100644 --- a/table_test.go +++ b/table_test.go @@ -1069,6 +1069,7 @@ func TestProbeReportsTheTablesADrawPins(t *testing.T) { } { a := splitArm(c.path, nil) head := f.root.children[a.head].(*table) + a.steps = compilePath(head, a.tail).steps tr := tableReadOf(head, a, nil) var sels []string for _, s := range tr.sels {