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

Function convertMacroCallsToString

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

Source from the content-addressed store, hash-verified

2761}
2762
2763func convertMacroCallsToString(source *ast.SourceInfo) string {
2764 macroCalls := source.MacroCalls()
2765 keys := make([]int64, len(macroCalls))
2766 adornedStrings := make([]string, len(macroCalls))
2767 i := 0
2768 for k := range macroCalls {
2769 keys[i] = k
2770 i++
2771 }
2772 fac := ast.NewExprFactory()
2773 // Sort the keys in descending order to create a stable ordering for tests and improve readability.
2774 sort.Slice(keys, func(i, j int) bool { return keys[i] > keys[j] })
2775 i = 0
2776 for _, key := range keys {
2777 call := macroCalls[int64(key)].AsCall()
2778 var callWithID ast.Expr
2779 if call.IsMemberFunction() {
2780 callWithID = fac.NewMemberCall(int64(key), call.FunctionName(), call.Target(), call.Args()...)
2781 } else {
2782 callWithID = fac.NewCall(int64(key), call.FunctionName(), call.Args()...)
2783 }
2784 adornedStrings[i] = debug.ToAdornedDebugString(
2785 callWithID,
2786 &kindAndIDAdorner{sourceInfo: source})
2787 i++
2788 }
2789 return strings.Join(adornedStrings, ",\n")
2790}
2791
2792func TestParse(t *testing.T) {
2793 for _, pratt := range []bool{false, true} {

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