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

Method eval

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

Source from the content-addressed store, hash-verified

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