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

Function TestReceiverVarArgMacro

parser/macro_test.go:24–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestReceiverVarArgMacro(t *testing.T) {
25 noopExpander := func(meh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) {
26 return nil, nil
27 }
28 varArgMacro := NewReceiverVarArgMacro("varargs", noopExpander,
29 MacroDocs(`convert variable argument lists to a list literal`),
30 MacroExamples(`varargs(1,2,3) // [1, 2, 3]`))
31 if varArgMacro.ArgCount() != 0 {
32 t.Errorf("ArgCount() got %d, wanted 0", varArgMacro.ArgCount())
33 }
34 if varArgMacro.Function() != "varargs" {
35 t.Errorf("Function() got %q, wanted 'varargs'", varArgMacro.Function())
36 }
37 if varArgMacro.MacroKey() != "varargs:*:true" {
38 t.Errorf("MacroKey() got %q, wanted 'varargs:*:true'", varArgMacro.MacroKey())
39 }
40 if !varArgMacro.IsReceiverStyle() {
41 t.Errorf("IsReceiverStyle() got %t, wanted true", varArgMacro.IsReceiverStyle())
42 }
43}
44
45func TestDocumentation(t *testing.T) {
46 noopExpander := func(meh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) {

Callers

nothing calls this directly

Calls 7

NewReceiverVarArgMacroFunction · 0.70
MacroDocsFunction · 0.70
MacroExamplesFunction · 0.70
ArgCountMethod · 0.65
FunctionMethod · 0.65
MacroKeyMethod · 0.65
IsReceiverStyleMethod · 0.65

Tested by

no test coverage detected