MCPcopy Create free account
hub / github.com/expr-lang/expr / TestVM_OpCall_InvalidNumberOfArguments

Function TestVM_OpCall_InvalidNumberOfArguments

vm/vm_test.go:1527–1541  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1525}
1526
1527func TestVM_OpCall_InvalidNumberOfArguments(t *testing.T) {
1528 // Test that the VM validates argument count at runtime.
1529 // Compile without Env() so compiler generates OpCall without type info.
1530 program, err := expr.Compile(`fn(1, 2)`)
1531 require.NoError(t, err)
1532
1533 // Run with a function that has different arity
1534 env := map[string]any{
1535 "fn": func(a int) int { return a },
1536 }
1537
1538 _, err = expr.Run(program, env)
1539 require.Error(t, err)
1540 require.Contains(t, err.Error(), "invalid number of arguments")
1541}
1542
1543func TestVM_OpCall_InvalidNumberOfArguments_Variadic(t *testing.T) {
1544 // Test variadic function with too few arguments.

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
ErrorFunction · 0.92
ContainsFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…