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

Function TestRun_FastMethods

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

Source from the content-addressed store, hash-verified

213}
214
215func TestRun_FastMethods(t *testing.T) {
216 input := `hello() + world()`
217
218 tree, err := parser.Parse(input)
219 require.NoError(t, err)
220
221 env := map[string]any{
222 "hello": func(...any) any { return "hello " },
223 "world": func(...any) any { return "world" },
224 }
225 funcConf := conf.New(env)
226 _, err = checker.Check(tree, funcConf)
227 require.NoError(t, err)
228
229 program, err := compiler.Compile(tree, funcConf)
230 require.NoError(t, err)
231
232 out, err := vm.Run(program, env)
233 require.NoError(t, err)
234
235 require.Equal(t, "hello world", out)
236}
237
238func TestRun_InnerMethodWithError(t *testing.T) {
239 input := `InnerEnv.WillError("yes")`

Callers

nothing calls this directly

Calls 7

ParseFunction · 0.92
NoErrorFunction · 0.92
NewFunction · 0.92
CheckFunction · 0.92
CompileFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…