From 350514b60e2dab05f8b40151b15bfb44e97b1bd5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 5 Oct 2026 12:25:32 +0200 Subject: [PATCH] Test a calc reading one operand twice --- calc_test.go | 3 +++ internal/grammar/format_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/calc_test.go b/calc_test.go index 80d9473..68fa29f 100644 --- a/calc_test.go +++ b/calc_test.go @@ -75,6 +75,9 @@ func TestCalcFields(t *testing.T) { if got := mustRender(t, engine(1), `{"format":"{calc(a - b)}","a":{"format":"{n}","n":"10"},"b":"3"}`); got != "7" { t.Fatalf("calc(a - b) = %q, want 7", got) } + if got := mustRender(t, engine(1), `{"format":"{calc(b * (a - b))}","a":"10","b":"3"}`); got != "21" { + t.Fatalf("calc(b * (a - b)) = %q, want 21", got) + } } // TestCalcNonNumericIsNaN pins the never-fail rule: a field that sometimes does diff --git a/internal/grammar/format_test.go b/internal/grammar/format_test.go index 2c6a97b..d7b0221 100644 --- a/internal/grammar/format_test.go +++ b/internal/grammar/format_test.go @@ -14,8 +14,8 @@ func TestSplitArgsQuotesOutsideSelectors(t *testing.T) { "/geo.US.locality[O'Fallon].name, 2": {"/geo.US.locality[O'Fallon].name", "2"}, "'[a,b]'": {"'[a,b]'"}, } { - if got := SplitArgs(in); !reflect.DeepEqual(got, want) { - t.Errorf("SplitArgs(%q) = %q, want %q", in, got, want) + if got := splitArgs(in); !reflect.DeepEqual(got, want) { + t.Errorf("splitArgs(%q) = %q, want %q", in, got, want) } } }