(t *testing.T)
| 107 | } |
| 108 | |
| 109 | func TestCall(t *testing.T) { |
| 110 | fac := ast.NewExprFactory() |
| 111 | expr := fac.NewCall(1, "size", fac.NewLiteral(2, types.String("hello"))) |
| 112 | if expr.Kind() != ast.CallKind { |
| 113 | t.Fatalf("NewCall() produced non-call expression: %v", expr.Kind()) |
| 114 | } |
| 115 | call := expr.AsCall() |
| 116 | if call.FunctionName() != "size" { |
| 117 | t.Errorf("Function() got %s, wanted 'size''", call.FunctionName()) |
| 118 | } |
| 119 | if len(call.Args()) != 1 { |
| 120 | t.Errorf("Args() got %v, wanted one", call.Args()) |
| 121 | } |
| 122 | if call.IsMemberFunction() { |
| 123 | t.Error("IsMemberFunction() got true, wanted false") |
| 124 | } |
| 125 | if call.Target().ID() != 0 { |
| 126 | t.Errorf("empty Target() got %d, wanted 0", call.Target().ID()) |
| 127 | } |
| 128 | expr.RenumberIDs(testIDGen(100)) |
| 129 | if expr.ID() != 101 { |
| 130 | t.Errorf("expr.ID() got %d, wanted 101 after RenumberIDs", expr.ID()) |
| 131 | } |
| 132 | if expr.AsCall().Args()[0].ID() != 102 { |
| 133 | t.Errorf("Args()[0].ID() got %d, wanted 102 after RenumberIDs", expr.AsCall().Args()[0].ID()) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func TestMemberCall(t *testing.T) { |
| 138 | fac := ast.NewExprFactory() |
nothing calls this directly
no test coverage detected