(t *testing.T)
| 60 | } |
| 61 | |
| 62 | func 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 | } |
nothing calls this directly
no test coverage detected