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

Function TestRun_MethodWithError

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

Source from the content-addressed store, hash-verified

190}
191
192func TestRun_MethodWithError(t *testing.T) {
193 input := `WillError("yes")`
194
195 tree, err := parser.Parse(input)
196 require.NoError(t, err)
197
198 env := ErrorEnv{}
199 funcConf := conf.New(env)
200 _, err = checker.Check(tree, funcConf)
201 require.NoError(t, err)
202
203 program, err := compiler.Compile(tree, funcConf)
204 require.NoError(t, err)
205
206 out, err := vm.Run(program, env)
207 require.EqualError(t, err, "error (1:1)\n | WillError(\"yes\")\n | ^")
208 require.Equal(t, nil, out)
209
210 selfErr := errors.Unwrap(err)
211 require.NotNil(t, err)
212 require.Equal(t, "error", selfErr.Error())
213}
214
215func TestRun_FastMethods(t *testing.T) {
216 input := `hello() + world()`

Callers

nothing calls this directly

Calls 11

ParseFunction · 0.92
NoErrorFunction · 0.92
NewFunction · 0.92
CheckFunction · 0.92
CompileFunction · 0.92
RunFunction · 0.92
EqualErrorFunction · 0.92
EqualFunction · 0.92
NotNilFunction · 0.92
UnwrapMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…