Test a name read before its binder links, and that every record carries its shape once loaded

This commit is contained in:
2026-10-05 22:15:05 +02:00
committed by Lillem4n
parent 34a0fb3a18
commit cdc82a99c6
2 changed files with 34 additions and 0 deletions
+13
View File
@@ -423,3 +423,16 @@ func TestAFieldBindingReadOutsideWhatItBindsLoads(t *testing.T) {
t.Errorf("NewTemplate = %v, want a read of n from x.z, outside x.y, accepted", err)
}
}
func TestANameReadBeforeItsBinderLinks(t *testing.T) {
dir := writeData(t, map[string]string{
"person": `{"format":"{first} {last}","first":["Ada","Bo","Cy"],"last":["Byron","Ek","Lind"]}`,
"row": `{"format":"{a}|{b}","a":"{p}","b":"{/person as p}{p.first} {p.last}"}`,
})
f := newGenerator(t, dir, WithSeed(2))
for i := 0; i < 100; i++ {
if a, b, _ := strings.Cut(fake(t, f, "row"), "|"); a != b {
t.Fatalf("a = %q, b = %q, want one pick of p", a, b)
}
}
}