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

Function TestDocumentation

cel/macro_test.go:62–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestDocumentation(t *testing.T) {
63 noopExpander := func(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) {
64 return nil, nil
65 }
66 varArgMacro := ReceiverVarArgMacro("varargs", noopExpander,
67 MacroDocs(`convert variable argument lists to a list literal`),
68 MacroExamples(`fn.varargs(1,2,3) // fn([1, 2, 3])`))
69 doc, ok := varArgMacro.(common.Documentor)
70 if !ok {
71 t.Fatal("macro does not implement Documenter interface")
72 }
73 d := doc.Documentation()
74 if d.Kind != common.DocMacro {
75 t.Errorf("Documentation() got kind %v, wanted DocMacro", d.Kind)
76 }
77 if d.Name != varArgMacro.Function() {
78 t.Errorf("Documentation() got name %q, wanted %q", d.Name, varArgMacro.Function())
79 }
80 if d.Description != `convert variable argument lists to a list literal` {
81 t.Errorf("Documentation() got description %q, wanted %q", d.Description, `convert variable argument lists to a list literal`)
82 }
83 if len(d.Children) != 1 {
84 t.Fatalf("macro documentation children got: %d", len(d.Children))
85 }
86 if d.Children[0].Description != `fn.varargs(1,2,3) // fn([1, 2, 3])` {
87 t.Errorf("macro documentation Children[0] got %s, wanted %s", d.Children[0].Description,
88 `fn.varargs(1,2,3) // fn([1, 2, 3])`)
89 }
90}

Callers

nothing calls this directly

Calls 5

ReceiverVarArgMacroFunction · 0.85
MacroDocsFunction · 0.70
MacroExamplesFunction · 0.70
DocumentationMethod · 0.65
FunctionMethod · 0.65

Tested by

no test coverage detected