Pin the calc stream against a moving operand

The calc case drew from single-element lists, so its pinned bytes were
constant wherever the rng sat — it could not have caught a change to how many
draws a calc consumes, which is exactly what the operand hold changed.
Multi-element lists make that stream a pinned fact, and every pinned pair
multiplies correctly, so the hold is pinned with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
M
2026-08-31 13:42:16 +02:00
committed by lilleman-tw
parent 2dbc9b1f9f
commit 1ba9185edc
+2 -2
View File
@@ -8,7 +8,7 @@ import "testing"
func TestSeededOutputIsStable(t *testing.T) { func TestSeededOutputIsStable(t *testing.T) {
dir := writeData(t, map[string]string{ dir := writeData(t, map[string]string{
"alt": `{"format":"{a|b}","a":["A"],"b":["B"]}`, "alt": `{"format":"{a|b}","a":["A"],"b":["B"]}`,
"calc": `{"format":"{net} x {qty} = {calc(net * qty, 2)}","net":["19.99"],"qty":["3"]}`, "calc": `{"format":"{net} x {qty} = {calc(net * qty, 2)}","net":["19.99","5.00","100.00"],"qty":["2","3","7"]}`,
"classes": `{"format":"00-11-AA-aa"}`, "classes": `{"format":"00-11-AA-aa"}`,
"escapes": `{"format":"#0#1#A#a##{x}","x":["!"]}`, "escapes": `{"format":"#0#1#A#a##{x}","x":["!"]}`,
"funcs": `{"format":"{hex(6)} {int(10,99)} {float(0,1,3)} {nanoid(5)} {seq()}"}`, "funcs": `{"format":"{hex(6)} {int(10,99)} {float(0,1,3)} {nanoid(5)} {seq()}"}`,
@@ -20,7 +20,7 @@ func TestSeededOutputIsStable(t *testing.T) {
}) })
want := map[string][]string{ want := map[string][]string{
"alt": {"A", "B", "A", "A"}, "alt": {"A", "B", "A", "A"},
"calc": {"19.99 x 3 = 59.97", "19.99 x 3 = 59.97", "19.99 x 3 = 59.97", "19.99 x 3 = 59.97"}, "calc": {"100.00 x 3 = 300.00", "100.00 x 3 = 300.00", "100.00 x 7 = 700.00", "5.00 x 3 = 15.00"},
"classes": {"49-74-VY-gj", "38-68-RP-xo", "47-68-IB-hs", "91-89-LP-gk"}, "classes": {"49-74-VY-gj", "38-68-RP-xo", "47-68-IB-hs", "91-89-LP-gk"},
"escapes": {"01Aa#!", "01Aa#!", "01Aa#!", "01Aa#!"}, "escapes": {"01Aa#!", "01Aa#!", "01Aa#!", "01Aa#!"},
"funcs": {"0016a2 33 0.649 k4Kwj 1", "a00c07 84 0.175 6UjGv 2", "f70eb8 12 0.390 p5p6g 3", "9048a3 90 0.531 I3Aqv 4"}, "funcs": {"0016a2 33 0.649 k4Kwj 1", "a00c07 84 0.175 6UjGv 2", "f70eb8 12 0.390 p5p6g 3", "9048a3 90 0.531 I3Aqv 4"},