You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It returns false which is correct from the point of view of collection library. But what we would expect from specification?
159
+
It returns false which is correct from the point of view of collection library.
160
+
But what we would expect from specification?
165
161
166
162
[[[
167
163
#(1 2 3) asOrderedCollection should equal: #(1 2 3).
@@ -170,9 +166,10 @@ It returns false which is correct from the point of view of collection library.
170
166
It would be not suitable to fail because it will force us to always think about collection type when we would like assert their equality.
171
167
In fact we are supposed to assert collection items with this expression and not instances of collections.
172
168
169
+
So this expression will not fail in StateSpecs. And to achieve its equality specification uses specific message ==#checkStateSpecsEqualityTo:== instead of standart #=.
173
170
174
-
So this expression will not fail in StateSpecs. And to achieve it equality specification uses specific message ==#checkStateSpecsEqualityTo:== instead of standart #=.
175
-
Default Object implementation calls #=. But some classes redefine it with appropriate logic to provide as less restrictive behaviour as possible.
171
+
Default Object implementation calls #=.
172
+
But some classes redefine it with appropriate logic to provide as less restrictive behaviour as possible.
176
173
177
174
Idea is that general equality specification should be as much simple equality as possible with enough restrictions. And if you want some extra details you should use different explicit specification which describes them.
178
175
In case of collections you should check for collection class explicitly if it is important for your business case where you use specification:
@@ -188,17 +185,19 @@ actual should equal: expected.
188
185
Following this logic StateSpecs do not check order when compare basic collection classes:
189
186
190
187
[[[
191
-
#(1 2 3) should equal: #(2 1 3). "will not fail"
192
-
#(1 2 3) asSet should equal: #(2 1 3). "will not fail"
188
+
#(1 2 3) should equal: #(2 1 3).
189
+
>>> true
190
+
#(1 2 3) asSet should equal: #(2 1 3).
191
+
>>> true
193
192
]]]
194
193
195
-
When order is importantuse different message ==#equalInOrder:==:
194
+
When the order is important, use the message ==equalInOrder:==:
196
195
197
196
[[[
198
197
#(1 2 3) asOrderedCollection should equalInOrder: #(2 1 3).
198
+
>>> Fails #(1 2 3)" but it should equal in order to "#(2 1 3)
199
199
]]]
200
200
201
-
It fails with message: Got "#(1 2 3)" but it should equal in order to "#(2 1 3)".
202
201
203
202
204
203
There are collection classes like String or ByteArray which are supposed to be in order and which type is important. For them theses properties are always taken into account for equality comparison:
0 commit comments