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

Function TestBlockEval_BadBlock

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

Source from the content-addressed store, hash-verified

405}
406
407func TestBlockEval_BadBlock(t *testing.T) {
408 fac := ast.NewExprFactory()
409 blockExpr := fac.NewCall(
410 1, "cel.@block",
411 fac.NewCall(2, operators.Add,
412 fac.NewIdent(3, "@index1"),
413 fac.NewIdent(4, "@index0")),
414 fac.NewIdent(5, "x"),
415 )
416 blockAST := ast.NewAST(blockExpr, nil)
417 env, err := cel.NewEnv(
418 Bindings(BindingsVersion(1)),
419 cel.Variable("x", cel.StringType),
420 )
421 if err != nil {
422 t.Fatalf("cel.NewEnv(Bindings()) failed: %v", err)
423 }
424 _, err = env.PlanProgram(blockAST)
425 if err == nil {
426 t.Fatal("PlanProgram() succeeded, expected error")
427 }
428}
429
430func TestBlockEval_RuntimeErrors(t *testing.T) {
431 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 9

NewCallMethod · 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