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

Function TestAstToString

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

Source from the content-addressed store, hash-verified

130}
131
132func TestAstToString(t *testing.T) {
133 stdEnv, err := NewEnv()
134 if err != nil {
135 t.Fatalf("NewEnv() failed: %v", err)
136 }
137 in := "a + b - (c ? (-d + 4) : e)"
138 ast, iss := stdEnv.Parse(in)
139 if iss.Err() != nil {
140 t.Fatalf("stdEnv.Parse(%q) failed: %v", in, iss.Err())
141 }
142 expr, err := AstToString(ast)
143 if err != nil {
144 t.Fatalf("AstToString(ast) failed: %v", err)
145 }
146 if expr != in {
147 t.Errorf("got %v, wanted %v", expr, in)
148 }
149}
150
151func TestExprToString(t *testing.T) {
152 stdEnv, err := NewEnv(EnableMacroCallTracking())

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
AstToStringFunction · 0.85
ErrMethod · 0.80
NewEnvFunction · 0.70

Tested by

no test coverage detected