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

Function TestCheckedExprToAstMissingInfo

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

Source from the content-addressed store, hash-verified

288}
289
290func TestCheckedExprToAstMissingInfo(t *testing.T) {
291 stdEnv, err := NewEnv()
292 if err != nil {
293 t.Fatalf("NewEnv() failed: %v", err)
294 }
295 in := "10"
296 ast, iss := stdEnv.Parse(in)
297 if iss.Err() != nil {
298 t.Fatalf("stdEnv.Compile(%q) failed: %v", in, iss.Err())
299 }
300 if ast.ResultType() != decls.Dyn {
301 t.Fatalf("ast.ResultType() got %v, wanted 'dyn'", ast.ResultType())
302 }
303 expr, err := AstToParsedExpr(ast)
304 if err != nil {
305 t.Fatalf("AstToParsedExpr(ast) failed: %v", err)
306 }
307 checkedExpr := &exprpb.CheckedExpr{
308 TypeMap: map[int64]*exprpb.Type{expr.GetExpr().GetId(): decls.Int},
309 Expr: expr.GetExpr(),
310 }
311 ast2 := CheckedExprToAst(checkedExpr)
312 if !ast2.IsChecked() {
313 t.Fatal("CheckedExprToAst() did not produce a 'checked' ast")
314 }
315 if ast2.ResultType() != decls.Int {
316 t.Fatalf("ast2.ResultType() got %v, wanted 'int'", ast.ResultType())
317 }
318}
319
320func TestRefValueToValue_Error(t *testing.T) {
321 _, err := RefValueToValue(types.NewErr("test error"))

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected