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

Function parseMutabilityExpr

interpreter/mutability_test.go:66–80  ·  view source on GitHub ↗
(t *testing.T, expr string)

Source from the content-addressed store, hash-verified

64var hiddenTestVars = map[string]string{"a": "@a", "b": "@b"}
65
66func parseMutabilityExpr(t *testing.T, expr string) *ast.AST {
67 t.Helper()
68 p, err := parser.NewParser(
69 parser.Macros(append(parser.AllMacros, compreMacro, compre2Macro, bindMacro, insertMacro)...),
70 )
71 if err != nil {
72 t.Fatalf("parser.NewParser() failed: %v", err)
73 }
74 parsed, errs := p.Parse(common.NewTextSource(expr))
75 if len(errs.GetErrors()) != 0 {
76 t.Fatalf("Parse(%q) failed: %v", expr, errs.ToDisplayString())
77 }
78 hideTestVars(parsed.Expr())
79 return parsed
80}
81
82// hideTestVars renames identifiers and comprehension variables listed in hiddenTestVars.
83func hideTestVars(e ast.Expr) {

Callers 2

TestIsMutableAccuSafeFunction · 0.85

Calls 8

ParseMethod · 0.95
NewParserFunction · 0.92
MacrosFunction · 0.92
NewTextSourceFunction · 0.92
hideTestVarsFunction · 0.85
GetErrorsMethod · 0.80
ExprMethod · 0.65
ToDisplayStringMethod · 0.45

Tested by

no test coverage detected