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

Function deepBoolExpr

cel/io_test.go:364–385  ·  view source on GitHub ↗

deepBoolExpr builds a synthetic deeply nested proto Expr by stacking `depth` unary `!` calls on top of a boolean literal. A depth well above the 250 default but far below the Go stack limit keeps the test itself from overflowing while still exercising the depth guard.

(depth int)

Source from the content-addressed store, hash-verified

362// on top of a boolean literal. A depth well above the 250 default but far below the Go stack
363// limit keeps the test itself from overflowing while still exercising the depth guard.
364func deepBoolExpr(depth int) *exprpb.Expr {
365 expr := &exprpb.Expr{
366 Id: 1,
367 ExprKind: &exprpb.Expr_ConstExpr{
368 ConstExpr: &exprpb.Constant{
369 ConstantKind: &exprpb.Constant_BoolValue{BoolValue: true},
370 },
371 },
372 }
373 for i := 0; i < depth; i++ {
374 expr = &exprpb.Expr{
375 Id: int64(i + 2),
376 ExprKind: &exprpb.Expr_CallExpr{
377 CallExpr: &exprpb.Expr_Call{
378 Function: operators.LogicalNot,
379 Args: []*exprpb.Expr{expr},
380 },
381 },
382 }
383 }
384 return expr
385}
386
387func TestLoadedAstDepthLimit(t *testing.T) {
388 env, err := NewEnv()

Callers 1

TestLoadedAstDepthLimitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected