view is a helper function for building view expressions used in tests. name is the name of the view, attributes list the names of the attributes rendered by the view. name may use the format "name:view" in which case view is the name of the view used to render the attribute (when its type is a resul
(name string, params ...any)
| 84 | // name of the view used to render the attribute (when its type is a result |
| 85 | // type). |
| 86 | func view(name string, params ...any) *ViewExpr { |
| 87 | var obj Object = make([]*NamedAttributeExpr, len(params)/2) |
| 88 | for i := 0; i < len(params); i += 2 { |
| 89 | var ( |
| 90 | attName string |
| 91 | attView string |
| 92 | ) |
| 93 | { |
| 94 | n := params[i].(string) |
| 95 | elems := strings.Split(n, ":") |
| 96 | attName = elems[0] |
| 97 | if len(elems) > 1 { |
| 98 | attView = elems[1] |
| 99 | } |
| 100 | } |
| 101 | att := &AttributeExpr{Type: params[i+1].(DataType)} |
| 102 | if attView != "" { |
| 103 | att.Meta = MetaExpr{"view": []string{attView}} |
| 104 | } |
| 105 | obj[i/2] = &NamedAttributeExpr{Name: attName, Attribute: att} |
| 106 | } |
| 107 | att := &AttributeExpr{Type: &obj} |
| 108 | return &ViewExpr{Name: name, AttributeExpr: att} |
| 109 | } |
| 110 | |
| 111 | // resultType is a helper function that builds result type expressions used in |
| 112 | // tests. The arguments is a list of attribute name and type pairs followed by a |