Skip to content

Commit fc2185f

Browse files
committed
Fix pHashable property
1 parent de1ae9e commit fc2185f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tests/HashMapProperties.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ pHashable :: [(Key, Int)] -> [Int] -> Int -> Property
5454
pHashable xs is salt =
5555
x == y ==> hashWithSalt salt x === hashWithSalt salt y
5656
where
57-
ys = shuffle is xs
58-
x = HM.fromList xs
57+
xs' = L.nubBy (\(k,_) (k',_) -> k == k') xs
58+
ys = shuffle is xs'
59+
x = HM.fromList xs'
5960
y = HM.fromList ys
6061
-- Shuffle the list using indexes in the second
6162
shuffle :: [Int] -> [a] -> [a]

tests/HashSetProperties.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ pHashable :: [Key] -> [Int] -> Int -> Property
5353
pHashable xs is salt =
5454
x == y ==> hashWithSalt salt x === hashWithSalt salt y
5555
where
56-
ys = shuffle is xs
57-
x = S.fromList xs
56+
xs' = L.nub xs
57+
ys = shuffle is xs'
58+
x = S.fromList xs'
5859
y = S.fromList ys
5960
shuffle idxs = L.map snd
6061
. L.sortBy (comparing fst)

0 commit comments

Comments
 (0)