Test that a fresh read inside a named pick reads none of the pick

This commit is contained in:
2026-10-05 23:07:02 +02:00
committed by Lillem4n
parent f0f81b066e
commit dc9d962690
+12
View File
@@ -332,3 +332,15 @@ func TestAColumnReadingABoundColumnIsThatColumn(t *testing.T) {
t.Errorf("the pick was null %d times in 100 records, want both outcomes", nulls)
}
}
func TestAFreshReadInsideANamedPickReadsNoneOfThePick(t *testing.T) {
f := engine(5)
src := `{"format":"{w as p}{p.a}|{p.a.b}","w":{"format":"{a}","a":{"format":"{c}|{b}","b":["1","2","3"],"c":{"format":"{b}","b":["x","y","z"]}}}}`
want := regexp.MustCompile(`^[xyz]\|([123])\|([123])$`)
for i := 0; i < 100; i++ {
got := mustRender(t, f, src)
if m := want.FindStringSubmatch(got); m == nil || m[1] != m[2] {
t.Fatalf("draw %d = %q, want p.a's c drawn afresh and its b read from p's pick", i, got)
}
}
}