Move the builtin argument tests to builtins_test.go and checkFunc's cases to format_test.go

This commit is contained in:
2026-09-25 18:21:32 +02:00
committed by Lillem4n
parent 5e84b26a5f
commit 4b087df57e
2 changed files with 19 additions and 20 deletions
+5 -14
View File
@@ -120,6 +120,11 @@ func TestFormatCompileErrors(t *testing.T) {
`"{}"`, // empty token name
`{"format":"{a|}","a":"Q"}`, // empty alternation segment
`"{luhn(}"`, // malformed function token
`"{lower()}"`, // wrong arity
`"{nope()}"`, // unknown function
`"{luhn(x)}"`, // function given args it takes none of
`"{int(1)}"`, // wrong arity
`"{float(1,2)}"`, // wrong arity
} {
if _, err := compile(parse(t, bad)); err == nil {
t.Errorf("compile(%s) = nil error, want error", bad)
@@ -127,20 +132,6 @@ func TestFormatCompileErrors(t *testing.T) {
}
}
func TestArgErrorsNameTheSpelling(t *testing.T) {
for src, want := range map[string]string{
`"{float(1,2,02)}"`: "write 2",
`{"format":"{calc(a,02)}","a":"1"}`: "write 2",
`"{digits(+5)}"`: "write 5",
`"{hex(99999999999999999999)}"`: "exceeds the maximum",
`"{int(007,9)}"`: "write 7",
} {
if _, err := compile(parse(t, src)); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("compile(%s) = %v, want an error saying %q", src, err, want)
}
}
}
// TestSplitArgsQuotesOutsideSelectors pins the arg grammar: a comma splits outside a
// selector and outside a quoted layout, and a quote inside a selector is a name's text.
func TestSplitArgsQuotesOutsideSelectors(t *testing.T) {