Tests for finite float bounds, plain integer args, constant samples and divisors, the default separator, binding keys in paths, DEL in ascii, and an unheld path
Tests / vet + fmt + tests (pull_request) Failing after 42s

This commit is contained in:
2026-09-02 19:07:49 +02:00
parent 3d3efbb642
commit 7b28dc36d9
6 changed files with 74 additions and 16 deletions
+15
View File
@@ -245,3 +245,18 @@ func TestCalcOverANeverNumericOperandIsRejected(t *testing.T) {
}
}
}
func TestCalcConstantZeroDivisorIsRejected(t *testing.T) {
for _, bad := range []string{`"{calc(1/0)}"`, `"{calc(2/(1-1))}"`, `{"format":"{calc(x/y)}","x":"1","y":"0"}`, `{"format":"{calc(x/(y*2))}","x":"1","y":" 0 "}`} {
if _, err := compile(parse(t, bad)); err == nil || !strings.Contains(err.Error(), "zero") {
t.Errorf("compile(%s) = %v, want the constant zero divisor rejected", bad, err)
}
}
f := engine(1)
for i := 0; i < 50; i++ {
if got := mustRender(t, f, `{"format":"{calc(x/y)}","x":"1","y":["0","1"]}`); got == "+Inf" {
return
}
}
t.Fatal("a sometimes-zero divisor never printed +Inf in 50 draws")
}