@@ -16,7 +16,7 @@ import qualified Data.HashMap.Strict as HM
16
16
import qualified Data.HashMap.Lazy as HM
17
17
#endif
18
18
import qualified Data.Map as M
19
- import Test.QuickCheck (Arbitrary , Property , (==>) )
19
+ import Test.QuickCheck (Arbitrary , Property , (==>) , (===) )
20
20
import Test.Framework (Test , defaultMain , testGroup )
21
21
import Test.Framework.Providers.QuickCheck2 (testProperty )
22
22
@@ -49,6 +49,14 @@ pFoldable :: [(Int, Int)] -> Bool
49
49
pFoldable = (L. sort . Foldable. foldr (:) [] ) `eq`
50
50
(L. sort . Foldable. foldr (:) [] )
51
51
52
+ pHashable :: [(Key , Int )] -> [Int ] -> Int -> Property
53
+ pHashable xs is salt =
54
+ x == y ==> hashWithSalt salt x === hashWithSalt salt y
55
+ where
56
+ ys = L. map snd . L. sort . L. zip (is ++ [L. maximum (0 : is) + 1 .. ]) $ xs
57
+ x = HM. fromList xs
58
+ y = HM. fromList ys
59
+
52
60
------------------------------------------------------------------------
53
61
-- ** Basic interface
54
62
@@ -229,6 +237,7 @@ tests =
229
237
, testProperty " Read/Show" pReadShow
230
238
, testProperty " Functor" pFunctor
231
239
, testProperty " Foldable" pFoldable
240
+ , testProperty " Hashable" pHashable
232
241
]
233
242
-- Basic interface
234
243
, testGroup " basic interface"
0 commit comments