Simplify variadic function support and add a test for it

This commit is contained in:
2024-01-24 22:33:47 -08:00
parent 9bf56b50a4
commit 958a25d559
2 changed files with 21 additions and 11 deletions

View File

@@ -172,6 +172,16 @@ func TestMethodCall(t *testing.T) {
}
}
func TestVariadic(t *testing.T) {
res := execStr(t, `#(sprintf("%s %d", x, y))`, map[string]any{
"x": "test",
"y": 4,
})
if res != "test 4" {
t.Errorf("Expected %q, got %q", "test 4", res)
}
}
func execStr(t *testing.T, tmplStr string, vars map[string]any) string {
t.Helper()
tmpl, err := New().ParseString("test", tmplStr)