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

Function TestBlockEval_BadPlan

ext/bindings_test.go:381–406  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

379}
380
381func TestBlockEval_BadPlan(t *testing.T) {
382 fac := ast.NewExprFactory()
383 blockExpr := fac.NewCall(
384 1, "cel.@block",
385 fac.NewList(2, []ast.Expr{
386 fac.NewIdent(3, "x"),
387 fac.NewIdent(4, "@index0"),
388 }, []int32{}),
389 fac.NewCall(6, operators.Add,
390 fac.NewIdent(7, "@index1"),
391 fac.NewIdent(8, "@index0")),
392 fac.NewIdent(9, "x"),
393 )
394 blockAST := ast.NewAST(blockExpr, nil)
395 env, err := cel.NewEnv(
396 Bindings(BindingsVersion(1)),
397 cel.Variable("x", cel.StringType),
398 )
399 if err != nil {
400 t.Fatalf("cel.NewEnv(Bindings()) failed: %v", err)
401 }
402 _, err = env.PlanProgram(blockAST)
403 if err == nil {
404 t.Fatal("PlanProgram() succeeded, expected error")
405 }
406}
407
408func TestBlockEval_BadBlock(t *testing.T) {
409 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 10

NewCallMethod · 0.95
NewListMethod · 0.95
NewIdentMethod · 0.95
PlanProgramMethod · 0.95
NewExprFactoryFunction · 0.92
NewASTFunction · 0.92
NewEnvFunction · 0.92
VariableFunction · 0.92
BindingsFunction · 0.85
BindingsVersionFunction · 0.85

Tested by

no test coverage detected