Require each path's leaves, cover and table steps from compilePath

This commit is contained in:
2026-09-30 17:06:17 +02:00
committed by Lillem4n
parent a7c99dfb09
commit 0f58784a1b
2 changed files with 7 additions and 7 deletions
+6 -7
View File
@@ -9,8 +9,8 @@ import (
func TestPathCheckStopsAtAMissingSegment(t *testing.T) { func TestPathCheckStopsAtAMissingSegment(t *testing.T) {
n := compiled(t, `{"format":"{a}","a":{"format":"{b}","b":"leaf"}}`) n := compiled(t, `{"format":"{a}","a":{"format":"{b}","b":"leaf"}}`)
if leaves := pathLeaves(n, []string{"a", "b"}); len(leaves) != 1 { if leaves := compilePath(n, []string{"a", "b"}).leaves; len(leaves) != 1 {
t.Fatalf("pathLeaves(a.b) = %v, want the one leaf", leaves) t.Fatalf("compilePath(a.b).leaves = %v, want the one leaf", leaves)
} }
w := &pathCheck{tail: []string{"a", "nope", "deeper"}} w := &pathCheck{tail: []string{"a", "nope", "deeper"}}
_, err := w.run(n) _, err := w.run(n)
@@ -24,16 +24,15 @@ func TestPathCheckStopsAtAMissingSegment(t *testing.T) {
func TestPathCheckChoiceConsumesNoSegment(t *testing.T) { func TestPathCheckChoiceConsumesNoSegment(t *testing.T) {
n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`) n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`)
if leaves := pathLeaves(n, []string{"f"}); len(leaves) != 2 { if leaves := compilePath(n, []string{"f"}).leaves; len(leaves) != 2 {
t.Fatalf("pathLeaves through a choice = %v, want both variants' f", leaves) t.Fatalf("compilePath through a choice = %v, want both variants' f", leaves)
} }
} }
func TestPathCoverStopsAtAChoice(t *testing.T) { func TestPathCoverStopsAtAChoice(t *testing.T) {
n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`) n := compiled(t, `[{"format":"{f}","f":"1"},{"format":"{f}","f":"2"}]`)
leaf, err := (&pathCover{into: map[node]bool{}}).walk(n, []string{"f"}) if cover := compilePath(n, []string{"f"}).cover; cover != n {
if err != nil || leaf != n { t.Fatalf("cover through a choice = %v, want the choice itself", cover)
t.Fatalf("cover through a choice = %v, %v, want the choice itself", leaf, err)
} }
} }
+1
View File
@@ -1069,6 +1069,7 @@ func TestProbeReportsTheTablesADrawPins(t *testing.T) {
} { } {
a := splitArm(c.path, nil) a := splitArm(c.path, nil)
head := f.root.children[a.head].(*table) head := f.root.children[a.head].(*table)
a.steps = compilePath(head, a.tail).steps
tr := tableReadOf(head, a, nil) tr := tableReadOf(head, a, nil)
var sels []string var sels []string
for _, s := range tr.sels { for _, s := range tr.sels {