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

Function TestCompile_Expect

compiler/compiler_test.go:680–725  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

678}
679
680func TestCompile_Expect(t *testing.T) {
681 tests := []struct {
682 input string
683 option expr.Option
684 op vm.Opcode
685 arg int
686 }{
687 {
688 input: "1",
689 option: expr.AsKind(reflect.Int),
690 op: vm.OpCast,
691 arg: 0,
692 },
693 {
694 input: "1",
695 option: expr.AsInt64(),
696 op: vm.OpCast,
697 arg: 1,
698 },
699 {
700 input: "1",
701 option: expr.AsFloat64(),
702 op: vm.OpCast,
703 arg: 2,
704 },
705 {
706 input: "true",
707 option: expr.AsBool(),
708 op: vm.OpCast,
709 arg: 3,
710 },
711 }
712
713 for _, tt := range tests {
714 t.Run(tt.input, func(t *testing.T) {
715 program, err := expr.Compile(tt.input, tt.option)
716 require.NoError(t, err)
717
718 lastOp := program.Bytecode[len(program.Bytecode)-1]
719 lastArg := program.Arguments[len(program.Arguments)-1]
720
721 assert.Equal(t, tt.op, lastOp)
722 assert.Equal(t, tt.arg, lastArg)
723 })
724 }
725}

Callers

nothing calls this directly

Calls 8

AsKindFunction · 0.92
AsInt64Function · 0.92
AsFloat64Function · 0.92
AsBoolFunction · 0.92
CompileFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…