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

Function convertMacroCallsToString

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

Source from the content-addressed store, hash-verified

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