MCPcopy Index your code
hub / github.com/expr-lang/expr / TestRun_Helpers

Function TestRun_Helpers

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

Source from the content-addressed store, hash-verified

115}
116
117func TestRun_Helpers(t *testing.T) {
118 values := []any{
119 uint(1),
120 uint8(1),
121 uint16(1),
122 uint32(1),
123 uint64(1),
124 1,
125 int8(1),
126 int16(1),
127 int32(1),
128 int64(1),
129 float32(1),
130 float64(1),
131 }
132 ops := []string{"+", "-", "*", "/", "%", "==", ">=", "<=", "<", ">"}
133
134 for _, a := range values {
135 for _, b := range values {
136 for _, op := range ops {
137
138 if op == "%" {
139 switch a.(type) {
140 case float32, float64:
141 continue
142 }
143 switch b.(type) {
144 case float32, float64:
145 continue
146 }
147 }
148
149 input := fmt.Sprintf("a %v b", op)
150 env := map[string]any{
151 "a": a,
152 "b": b,
153 }
154
155 config := conf.CreateNew()
156
157 tree, err := parser.Parse(input)
158 require.NoError(t, err)
159
160 _, err = checker.Check(tree, config)
161 require.NoError(t, err)
162
163 program, err := compiler.Compile(tree, config)
164 require.NoError(t, err)
165
166 _, err = vm.Run(program, env)
167 require.NoError(t, err)
168 }
169 }
170 }
171}
172
173type ErrorEnv struct {
174 InnerEnv InnerEnv

Callers

nothing calls this directly

Calls 7

CreateNewFunction · 0.92
ParseFunction · 0.92
NoErrorFunction · 0.92
CheckFunction · 0.92
CompileFunction · 0.92
RunFunction · 0.92
SprintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…