MCPcopy
hub / github.com/expr-lang/expr / TestVM_CallN

Function TestVM_CallN

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

Source from the content-addressed store, hash-verified

705}
706
707func TestVM_CallN(t *testing.T) {
708 input := `fn(1, 2, 3)`
709
710 tree, err := parser.Parse(input)
711 require.NoError(t, err)
712
713 env := map[string]any{
714 "fn": func(args ...any) (any, error) {
715 sum := 0
716 for _, arg := range args {
717 sum += arg.(int)
718 }
719 return sum, nil
720 },
721 }
722
723 config := conf.New(env)
724 program, err := compiler.Compile(tree, config)
725 require.NoError(t, err)
726
727 out, err := vm.Run(program, env)
728 require.NoError(t, err)
729 require.Equal(t, 6, out)
730}
731
732// TestVM_IndexAndCountOperations tests the index and count manipulation opcodes directly
733func TestVM_IndexAndCountOperations(t *testing.T) {

Callers

nothing calls this directly

Calls 6

ParseFunction · 0.92
NoErrorFunction · 0.92
NewFunction · 0.92
CompileFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…