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

Function TestVM_DirectCallOpcodes

vm/vm_test.go:596–705  ·  view source on GitHub ↗

TestVM_DirectCallOpcodes tests the specialized call opcodes directly

(t *testing.T)

Source from the content-addressed store, hash-verified

594
595// TestVM_DirectCallOpcodes tests the specialized call opcodes directly
596func TestVM_DirectCallOpcodes(t *testing.T) {
597 tests := []struct {
598 name string
599 bytecode []vm.Opcode
600 args []int
601 consts []any
602 funcs []vm.Function
603 want any
604 wantErr bool
605 }{
606 {
607 name: "OpCall0",
608 bytecode: []vm.Opcode{vm.OpCall0},
609 args: []int{0},
610 funcs: []vm.Function{
611 func(args ...any) (any, error) {
612 return 42, nil
613 },
614 },
615 want: 42,
616 },
617 {
618 name: "OpCall1",
619 bytecode: []vm.Opcode{
620 vm.OpPush,
621 vm.OpCall1,
622 },
623 args: []int{0, 0},
624 consts: []any{10},
625 funcs: []vm.Function{
626 func(args ...any) (any, error) {
627 return args[0].(int) * 2, nil
628 },
629 },
630 want: 20,
631 },
632 {
633 name: "OpCall2",
634 bytecode: []vm.Opcode{
635 vm.OpPush,
636 vm.OpPush,
637 vm.OpCall2,
638 },
639 args: []int{0, 1, 0},
640 consts: []any{10, 5},
641 funcs: []vm.Function{
642 func(args ...any) (any, error) {
643 return args[0].(int) + args[1].(int), nil
644 },
645 },
646 want: 15,
647 },
648 {
649 name: "OpCall3",
650 bytecode: []vm.Opcode{
651 vm.OpPush,
652 vm.OpPush,
653 vm.OpPush,

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
ErrorFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…