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

Function TestVM_DirectBasicOpcodes

vm/vm_test.go:834–1300  ·  view source on GitHub ↗

TestVM_DirectBasicOpcodes tests basic opcodes directly

(t *testing.T)

Source from the content-addressed store, hash-verified

832
833// TestVM_DirectBasicOpcodes tests basic opcodes directly
834func TestVM_DirectBasicOpcodes(t *testing.T) {
835 tests := []struct {
836 name string
837 bytecode []vm.Opcode
838 args []int
839 consts []any
840 env any
841 want any
842 wantErr bool
843 }{
844 {
845 name: "OpLoadEnv",
846 bytecode: []vm.Opcode{
847 vm.OpLoadEnv, // Load entire environment
848 },
849 args: []int{0},
850 env: map[string]any{"key": "value"},
851 want: map[string]any{"key": "value"},
852 },
853 {
854 name: "OpTrue",
855 bytecode: []vm.Opcode{
856 vm.OpTrue,
857 },
858 args: []int{0},
859 want: true,
860 },
861 {
862 name: "OpFalse",
863 bytecode: []vm.Opcode{
864 vm.OpFalse,
865 },
866 args: []int{0},
867 want: false,
868 },
869 {
870 name: "OpNil",
871 bytecode: []vm.Opcode{
872 vm.OpNil,
873 },
874 args: []int{0},
875 want: nil,
876 },
877 {
878 name: "OpNegate int",
879 bytecode: []vm.Opcode{
880 vm.OpPush, // Push number
881 vm.OpNegate, // Negate it
882 },
883 args: []int{0, 0},
884 consts: []any{42},
885 want: -42,
886 },
887 {
888 name: "OpNegate float",
889 bytecode: []vm.Opcode{
890 vm.OpPush, // Push number
891 vm.OpNegate, // Negate it

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…