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

Function TestCheckedExprToAstMissingInfo

cel/io_test.go:331–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func TestCheckedExprToAstMissingInfo(t *testing.T) {
332 stdEnv, err := NewEnv()
333 if err != nil {
334 t.Fatalf("NewEnv() failed: %v", err)
335 }
336 in := "10"
337 ast, iss := stdEnv.Parse(in)
338 if iss.Err() != nil {
339 t.Fatalf("stdEnv.Compile(%q) failed: %v", in, iss.Err())
340 }
341 if ast.ResultType() != decls.Dyn {
342 t.Fatalf("ast.ResultType() got %v, wanted 'dyn'", ast.ResultType())
343 }
344 expr, err := AstToParsedExpr(ast)
345 if err != nil {
346 t.Fatalf("AstToParsedExpr(ast) failed: %v", err)
347 }
348 checkedExpr := &exprpb.CheckedExpr{
349 TypeMap: map[int64]*exprpb.Type{expr.GetExpr().GetId(): decls.Int},
350 Expr: expr.GetExpr(),
351 }
352 ast2 := CheckedExprToAst(checkedExpr)
353 if !ast2.IsChecked() {
354 t.Fatal("CheckedExprToAst() did not produce a 'checked' ast")
355 }
356 if ast2.ResultType() != decls.Int {
357 t.Fatalf("ast2.ResultType() got %v, wanted 'int'", ast.ResultType())
358 }
359}
360
361// deepBoolExpr builds a synthetic deeply nested proto Expr by stacking `depth` unary `!` calls
362// on top of a boolean literal. A depth well above the 250 default but far below the Go stack

Callers

nothing calls this directly

Calls 9

ParseMethod · 0.95
AstToParsedExprFunction · 0.85
CheckedExprToAstFunction · 0.85
ErrMethod · 0.80
GetExprMethod · 0.80
NewEnvFunction · 0.70
GetIdMethod · 0.65
ResultTypeMethod · 0.45
IsCheckedMethod · 0.45

Tested by

no test coverage detected