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

Function convertMacroCallsToString

parser/parser_test.go:2190–2217  ·  view source on GitHub ↗
(source *ast.SourceInfo)

Source from the content-addressed store, hash-verified

2188}
2189
2190func convertMacroCallsToString(source *ast.SourceInfo) string {
2191 macroCalls := source.MacroCalls()
2192 keys := make([]int64, len(macroCalls))
2193 adornedStrings := make([]string, len(macroCalls))
2194 i := 0
2195 for k := range macroCalls {
2196 keys[i] = k
2197 i++
2198 }
2199 fac := ast.NewExprFactory()
2200 // Sort the keys in descending order to create a stable ordering for tests and improve readability.
2201 sort.Slice(keys, func(i, j int) bool { return keys[i] > keys[j] })
2202 i = 0
2203 for _, key := range keys {
2204 call := macroCalls[int64(key)].AsCall()
2205 var callWithID ast.Expr
2206 if call.IsMemberFunction() {
2207 callWithID = fac.NewMemberCall(int64(key), call.FunctionName(), call.Target(), call.Args()...)
2208 } else {
2209 callWithID = fac.NewCall(int64(key), call.FunctionName(), call.Args()...)
2210 }
2211 adornedStrings[i] = debug.ToAdornedDebugString(
2212 callWithID,
2213 &kindAndIDAdorner{sourceInfo: source})
2214 i++
2215 }
2216 return strings.Join(adornedStrings, ",\n")
2217}
2218
2219func TestParse(t *testing.T) {
2220 defaultParser := newTestParser(t)

Callers 1

TestParseFunction · 0.85

Calls 11

NewMemberCallMethod · 0.95
NewCallMethod · 0.95
NewExprFactoryFunction · 0.92
ToAdornedDebugStringFunction · 0.92
SliceMethod · 0.65
AsCallMethod · 0.65
IsMemberFunctionMethod · 0.65
FunctionNameMethod · 0.65
TargetMethod · 0.65
ArgsMethod · 0.65
MacroCallsMethod · 0.45

Tested by

no test coverage detected