Skip to content

Commit 0c4fc7a

Browse files
committed
[test] MinimalHashable types: Implement CustomStringConvertible
This makes it easier to understand failure traces in test logs.
1 parent abd5f7f commit 0c4fc7a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

stdlib/private/StdlibUnittest/MinimalTypes.swift.gyb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public func < (
110110
///
111111
/// This type can be used to check that generic functions don't rely on any
112112
/// other conformances.
113-
public ${decl_keyword} ${Self} : Equatable, Hashable {
113+
public ${decl_keyword} ${Self} : Equatable, Hashable, CustomStringConvertible {
114114
public static var timesEqualEqualWasCalled: Int = 0
115115
public static var timesHashIntoWasCalled: Int = 0
116116

@@ -142,6 +142,10 @@ public ${decl_keyword} ${Self} : Equatable, Hashable {
142142
${Self}.timesHashIntoWasCalled += 1
143143
${Self}.hashIntoImpl.value(value, &hasher)
144144
}
145+
146+
public var description: String {
147+
return "${Self}(value: \(value), identity: \(identity))"
148+
}
145149
}
146150

147151
public func == (
@@ -170,7 +174,8 @@ public var ${Self}_hashIntoImpl = ResettableValue<(Any, inout _Hasher) -> Void>(
170174
///
171175
/// This type can be used to check that generic functions don't rely on any
172176
/// other conformances.
173-
public ${decl_keyword} ${Self}<Wrapped> : Equatable, Hashable {
177+
public ${decl_keyword} ${Self}<Wrapped>
178+
: Equatable, Hashable, CustomStringConvertible {
174179
public var value: Wrapped
175180
public var identity: Int
176181

@@ -193,6 +198,10 @@ public ${decl_keyword} ${Self}<Wrapped> : Equatable, Hashable {
193198
${Self}_timesHashIntoWasCalled += 1
194199
return ${Self}_hashIntoImpl.value(value, &hasher)
195200
}
201+
202+
public var description: String {
203+
return "${Self}(value: \(value), identity: \(identity))"
204+
}
196205
}
197206

198207
public func == <Wrapped>(

0 commit comments

Comments
 (0)