Permalink
2a9d272 Feb 1, 2017
@krzysztofzablocki @ilyapuchka
15 lines (14 sloc) 1023 Bytes
{% for type in types.implementing.AutoDiffable|!protocol %}
extension {{ type.name }}{% if not type.supertype.implements.AutoDiffable %}: Diffable{% endif %} {
{% if type.based.Type %}override {% endif %}func diffAgainst(_ object: Any?) -> DiffableResult {
let results = DiffableResult()
guard let {% if type.storedVariables|!annotated:"skipEquality" %}rhs{% else %}_{% endif %} = object as? {{ type.name }} else {
results.append("Incorrect type <expected: {{ type.name }}, received: \(type(of: object))>")
return results
}
{% for variable in type.storedVariables|!annotated:"skipEquality" %}results.append(contentsOf: DiffableResult(identifier: "{{ variable.name }}").trackDifference(actual: self.{{ variable.name }}, expected: rhs.{{ variable.name }}))
{% endfor %}
{% if type.supertype.implements.AutoDiffable %}results.append(contentsOf: super.diffAgainst(object))
return results{% else %}return results{% endif %}
}
}{% endfor %}