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)
| 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. |
| 364 | func 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 | |
| 387 | func TestLoadedAstDepthLimit(t *testing.T) { |
| 388 | env, err := NewEnv() |
no outgoing calls
no test coverage detected