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

Method setup

policy/compiler_test.go:326–350  ·  view source on GitHub ↗
(t testing.TB, env *cel.Env, ast *cel.Ast)

Source from the content-addressed store, hash-verified

324}
325
326func (r *runner) setup(t testing.TB, env *cel.Env, ast *cel.Ast) {
327 t.Helper()
328 pExpr, err := cel.AstToString(ast)
329 if err != nil {
330 t.Fatalf("cel.AstToString() failed: %v", err)
331 }
332 _, err = cel.AstToCheckedExpr(ast)
333 if err != nil {
334 t.Fatalf("cel.AstToCheckedExpr() failed: %v", err)
335 }
336 if r.expr != "" && normalize(pExpr) != normalize(r.expr) {
337 t.Errorf("cel.AstToString() got %s, wanted %s", pExpr, r.expr)
338 }
339 wantBlockExt := strings.Contains(pExpr, "cel.@block")
340 hasBlockExt := ast.NativeRep().SourceInfo().HasExtension(celBlockExt.ID, celBlockExt.Version)
341 if hasBlockExt != wantBlockExt {
342 t.Errorf("SourceInfo().HasExtension('cel_block', 1.1) got %v, wanted %v", hasBlockExt, wantBlockExt)
343 }
344 prg, err := env.Program(ast, cel.EvalOptions(cel.OptOptimize))
345 if err != nil {
346 t.Fatalf("env.Program() failed: %v", err)
347 }
348 r.env = env
349 r.prg = prg
350}
351
352func (r *runner) run(t *testing.T) {
353 tests := readTestSuite(t, fmt.Sprintf("testdata/%s/tests.yaml", r.name))

Callers 7

TestRuleComposerUnnestFunction · 0.80
TestCompileFunction · 0.80
BenchmarkCompileFunction · 0.80
TestFrameResolveNameFunction · 0.80
TestFrameParentFunction · 0.80

Calls 9

AstToStringFunction · 0.92
AstToCheckedExprFunction · 0.92
EvalOptionsFunction · 0.92
HasExtensionMethod · 0.80
NativeRepMethod · 0.80
ProgramMethod · 0.80
normalizeFunction · 0.70
ContainsMethod · 0.65
SourceInfoMethod · 0.45

Tested by

no test coverage detected