From b726edd7cb306284166bfa0094b5c14018acf024 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 5 Oct 2026 23:22:43 +0200 Subject: [PATCH] Test that a fresh read and a named read key their levels from the head they walk from to their leaf --- pick_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pick_test.go b/pick_test.go index 52f40cc..1619bd4 100644 --- a/pick_test.go +++ b/pick_test.go @@ -344,3 +344,19 @@ func TestAFreshReadInsideANamedPickSharesNoValueWithIt(t *testing.T) { } } } + +func TestEveryReadKeysEachLevelFromItsHeadToItsLeaf(t *testing.T) { + root := compiled(t, `{"format":"{place.geo as g}{g.town.zip} {g.town} {x.y.z}","place":{"format":"{geo}","geo":{"format":"{town}","town":{"format":"{zip}","zip":"1"}}},"x":{"format":"{y}","y":{"format":"{z}","z":"2"}}}`).(*template) + want := map[string]string{ + "g.town.zip": "[ geo geo.town geo.town.zip]", + "g.town": "[ geo geo.town]", + "x.y.z": "[x x.y x.y.z]", + } + for _, o := range root.compiled.ops { + for _, a := range o.arms { + if got := fmt.Sprint(a.levels); got != want[a.spelling] { + t.Errorf("{%s} keys its levels %s, want %s", a.spelling, got, want[a.spelling]) + } + } + } +}