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