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

Function TestDocumentation

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

Source from the content-addressed store, hash-verified

43}
44
45func TestDocumentation(t *testing.T) {
46 noopExpander := func(meh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) {
47 return nil, nil
48 }
49 varArgMacro := NewReceiverVarArgMacro("varargs", noopExpander,
50 MacroDocs(`convert variable argument lists to a list literal`),
51 MacroExamples(`varargs(1,2,3) // [1, 2, 3]`))
52 doc, ok := varArgMacro.(common.Documentor)
53 if !ok {
54 t.Fatal("macro does not implement Documenter interface")
55 }
56 d := doc.Documentation()
57 if d.Kind != common.DocMacro {
58 t.Errorf("Documentation() got kind %v, wanted DocMacro", d.Kind)
59 }
60 if d.Name != varArgMacro.Function() {
61 t.Errorf("Documentation() got name %q, wanted %q", d.Name, varArgMacro.Function())
62 }
63 if d.Description != `convert variable argument lists to a list literal` {
64 t.Errorf("Documentation() got description %q, wanted %q", d.Description, `convert variable argument lists to a list literal`)
65 }
66 if len(d.Children) != 1 {
67 t.Fatalf("macro documentation children got: %d", len(d.Children))
68 }
69 if d.Children[0].Description != `varargs(1,2,3) // [1, 2, 3]` {
70 t.Errorf("macro documentation Children[0] got %s, wanted %s", d.Children[0].Description, `varargs(1,2,3) // [1, 2, 3]`)
71 }
72}

Callers

nothing calls this directly

Calls 5

NewReceiverVarArgMacroFunction · 0.70
MacroDocsFunction · 0.70
MacroExamplesFunction · 0.70
DocumentationMethod · 0.65
FunctionMethod · 0.65

Tested by

no test coverage detected