(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestTaggedAttribute(t *testing.T) { |
| 11 | tagged := &AttributeExpr{ |
| 12 | Type: &Object{ |
| 13 | &NamedAttributeExpr{ |
| 14 | Name: "Foo", |
| 15 | Attribute: &AttributeExpr{ |
| 16 | Meta: MetaExpr{"foo": []string{"foo"}}, |
| 17 | }, |
| 18 | }, |
| 19 | }, |
| 20 | } |
| 21 | cases := map[string]struct { |
| 22 | a *AttributeExpr |
| 23 | expected string |
| 24 | }{ |
| 25 | "tagged attribute": { |
| 26 | a: tagged, |
| 27 | expected: "Foo", |
| 28 | }, |
| 29 | "not object": { |
| 30 | a: &AttributeExpr{ |
| 31 | Type: Boolean, |
| 32 | }, |
| 33 | expected: "", |
| 34 | }, |
| 35 | "no meta": { |
| 36 | a: &AttributeExpr{ |
| 37 | Type: &Object{ |
| 38 | &NamedAttributeExpr{ |
| 39 | Name: "Foo", |
| 40 | Attribute: &AttributeExpr{}, |
| 41 | }, |
| 42 | }, |
| 43 | }, |
| 44 | expected: "", |
| 45 | }, |
| 46 | "extended": { |
| 47 | a: &AttributeExpr{ |
| 48 | Type: &Object{ |
| 49 | &NamedAttributeExpr{ |
| 50 | Name: "bar", |
| 51 | Attribute: &AttributeExpr{Type: String}, |
| 52 | }, |
| 53 | }, |
| 54 | Bases: []DataType{ |
| 55 | &UserTypeExpr{ |
| 56 | TypeName: "Extended", |
| 57 | AttributeExpr: tagged, |
| 58 | }, |
| 59 | }, |
| 60 | }, |
| 61 | expected: "Foo", |
| 62 | }, |
| 63 | "recursively extended": { |
| 64 | a: &AttributeExpr{ |
| 65 | Type: &Object{ |
| 66 | &NamedAttributeExpr{ |
| 67 | Name: "bar", |
nothing calls this directly
no test coverage detected