(t *testing.T)
| 135 | } |
| 136 | |
| 137 | func TestMemberCall(t *testing.T) { |
| 138 | fac := ast.NewExprFactory() |
| 139 | expr := fac.NewMemberCall(1, "size", fac.NewLiteral(2, types.String("hello"))) |
| 140 | if expr.Kind() != ast.CallKind { |
| 141 | t.Fatalf("NewCall() produced non-call expression: %v", expr.Kind()) |
| 142 | } |
| 143 | call := expr.AsCall() |
| 144 | if call.FunctionName() != "size" { |
| 145 | t.Errorf("Function() got %s, wanted 'size''", call.FunctionName()) |
| 146 | } |
| 147 | if len(call.Args()) != 0 { |
| 148 | t.Errorf("Args() got %v, wanted zero", call.Args()) |
| 149 | } |
| 150 | if !call.IsMemberFunction() { |
| 151 | t.Error("IsMemberFunction() got false, wanted true") |
| 152 | } |
| 153 | if call.Target().ID() != 2 { |
| 154 | t.Errorf("Target() got %d, wanted 2", call.Target().ID()) |
| 155 | } |
| 156 | expr.RenumberIDs(testIDGen(100)) |
| 157 | if expr.ID() != 101 { |
| 158 | t.Errorf("expr.ID() got %d, wanted 101 after RenumberIDs", expr.ID()) |
| 159 | } |
| 160 | if expr.AsCall().Target().ID() != 102 { |
| 161 | t.Errorf("Target().ID() got %d, wanted 102 after RenumberIDs", expr.AsCall().Target().ID()) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func TestCallNil(t *testing.T) { |
| 166 | expr := nilTestExpr(t) |
nothing calls this directly
no test coverage detected