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

Function TestCompile

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

Source from the content-addressed store, hash-verified

49}
50
51func TestCompile(t *testing.T) {
52 var tests = []struct {
53 code string
54 want vm.Program
55 }{
56 {
57 `65535`,
58 vm.Program{
59 Constants: []any{
60 math.MaxUint16,
61 },
62 Bytecode: []vm.Opcode{
63 vm.OpPush,
64 },
65 Arguments: []int{0},
66 },
67 },
68 {
69 `.5`,
70 vm.Program{
71 Constants: []any{
72 .5,
73 },
74 Bytecode: []vm.Opcode{
75 vm.OpPush,
76 },
77 Arguments: []int{0},
78 },
79 },
80 {
81 `true`,
82 vm.Program{
83 Bytecode: []vm.Opcode{
84 vm.OpTrue,
85 },
86 Arguments: []int{0},
87 },
88 },
89 {
90 `"string"`,
91 vm.Program{
92 Constants: []any{
93 "string",
94 },
95 Bytecode: []vm.Opcode{
96 vm.OpPush,
97 },
98 Arguments: []int{0},
99 },
100 },
101 {
102 `"string" == "string"`,
103 vm.Program{
104 Constants: []any{
105 "string",
106 },
107 Bytecode: []vm.Opcode{
108 vm.OpPush,

Callers

nothing calls this directly

Calls 7

CompileFunction · 0.92
EnvStruct · 0.92
OptimizeFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92
RunMethod · 0.80
DisassembleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…