Skip to content

Commit 63cc78b

Browse files
committed
Use larger input array for sortWith stability test
1 parent 86d30f5 commit 63cc78b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/Test/Data/Array.purs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,16 @@ testArray = do
287287
log "sortBy should reorder a list into ascending order based on the result of a comparison function"
288288
assert $ A.sortBy (flip compare) [1, 3, 2, 5, 6, 4] == [6, 5, 4, 3, 2, 1]
289289

290+
log "sortBy should not reorder elements that are equal according to a comparison function"
291+
let s1 = map (Tuple "a") (A.range 1 100)
292+
assert $ A.sortBy (comparing fst) s1 == s1
293+
290294
log "sortWith should reorder a list into ascending order based on the result of compare over a projection"
291295
assert $ A.sortWith identity [1, 3, 2, 5, 6, 4] == [1, 2, 3, 4, 5, 6]
292296

293-
log "sortWith should be stable"
294-
assert $ A.sortWith fst
295-
[Tuple "a" 1, Tuple "a" 2, Tuple "a" 3, Tuple "a" 4] ==
296-
[Tuple "a" 1, Tuple "a" 2, Tuple "a" 3, Tuple "a" 4]
297+
log "sortWith should not reorder elements that are equal according to a projection"
298+
let s2 = map (Tuple "a") (A.range 1 100)
299+
assert $ A.sortWith fst s2 == s2
297300

298301
log "take should keep the specified number of items from the front of an array, discarding the rest"
299302
assert $ (A.take 1 [1, 2, 3]) == [1]

0 commit comments

Comments
 (0)