MCPcopy Create free account
hub / github.com/cel-expr/cel-go / eval

Method eval

policy/compiler_test.go:464–478  ·  view source on GitHub ↗
(t testing.TB, expr string)

Source from the content-addressed store, hash-verified

462}
463
464func (r *runner) eval(t testing.TB, expr string) ref.Val {
465 wantExpr, iss := r.env.Compile(expr)
466 if iss.Err() != nil {
467 t.Fatalf("env.Compile(%q) failed :%v", expr, iss.Err())
468 }
469 prg, err := r.env.Program(wantExpr)
470 if err != nil {
471 t.Fatalf("env.Program(wantExpr) failed: %v", err)
472 }
473 out, _, err := prg.Eval(cel.NoVars())
474 if err != nil {
475 t.Fatalf("prg.Eval() failed: %v", err)
476 }
477 return out
478}
479
480func mustCompileExpr(t testing.TB, env *cel.Env, expr string) *cel.Ast {
481 t.Helper()

Callers 2

runMethod · 0.95
benchMethod · 0.95

Calls 5

NoVarsFunction · 0.92
ErrMethod · 0.80
ProgramMethod · 0.80
CompileMethod · 0.65
EvalMethod · 0.65

Tested by

no test coverage detected