Test that a fresh read and a named read key their levels from the head they walk from to their leaf

This commit is contained in:
2026-10-05 23:22:43 +02:00
committed by Lillem4n
parent 0293e800ae
commit b726edd7cb
+16
View File
@@ -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])
}
}
}
}