@@ -30,10 +30,10 @@ instance Hashable Key where
30
30
------------------------------------------------------------------------
31
31
-- ** Instances
32
32
33
- pEq :: [Key ] -> [Key ] -> Bool
33
+ pEq :: [Key ] -> [Key ] -> Property
34
34
pEq xs = (Set. fromList xs == ) `eq` (S. fromList xs == )
35
35
36
- pNeq :: [Key ] -> [Key ] -> Bool
36
+ pNeq :: [Key ] -> [Key ] -> Property
37
37
pNeq xs = (Set. fromList xs /= ) `eq` (S. fromList xs /= )
38
38
39
39
-- We cannot compare to `Data.Map` as ordering is different.
@@ -78,7 +78,7 @@ pOrdEq xs ys = case (compare x y, x == y) of
78
78
pReadShow :: [Key ] -> Bool
79
79
pReadShow xs = Set. fromList xs == read (show (Set. fromList xs))
80
80
81
- pFoldable :: [Int ] -> Bool
81
+ pFoldable :: [Int ] -> Property
82
82
pFoldable = (List. sort . Foldable. foldr (:) [] ) `eq`
83
83
(List. sort . Foldable. foldr (:) [] )
84
84
@@ -105,42 +105,42 @@ pHashable xs is salt =
105
105
------------------------------------------------------------------------
106
106
-- ** Basic interface
107
107
108
- pSize :: [Key ] -> Bool
108
+ pSize :: [Key ] -> Property
109
109
pSize = Set. size `eq` S. size
110
110
111
- pMember :: Key -> [Key ] -> Bool
111
+ pMember :: Key -> [Key ] -> Property
112
112
pMember k = Set. member k `eq` S. member k
113
113
114
- pInsert :: Key -> [Key ] -> Bool
114
+ pInsert :: Key -> [Key ] -> Property
115
115
pInsert a = Set. insert a `eq_` S. insert a
116
116
117
- pDelete :: Key -> [Key ] -> Bool
117
+ pDelete :: Key -> [Key ] -> Property
118
118
pDelete a = Set. delete a `eq_` S. delete a
119
119
120
120
------------------------------------------------------------------------
121
121
-- ** Combine
122
122
123
- pUnion :: [Key ] -> [Key ] -> Bool
123
+ pUnion :: [Key ] -> [Key ] -> Property
124
124
pUnion xs ys = Set. union (Set. fromList xs) `eq_`
125
125
S. union (S. fromList xs) $ ys
126
126
127
127
------------------------------------------------------------------------
128
128
-- ** Transformations
129
129
130
- pMap :: [Key ] -> Bool
130
+ pMap :: [Key ] -> Property
131
131
pMap = Set. map (+ 1 ) `eq_` S. map (+ 1 )
132
132
133
133
------------------------------------------------------------------------
134
134
-- ** Folds
135
135
136
- pFoldr :: [Int ] -> Bool
136
+ pFoldr :: [Int ] -> Property
137
137
pFoldr = (List. sort . foldrSet (:) [] ) `eq`
138
138
(List. sort . S. foldr (:) [] )
139
139
140
140
foldrSet :: (a -> b -> b ) -> b -> Set. Set a -> b
141
141
foldrSet = Set. foldr
142
142
143
- pFoldl' :: Int -> [Int ] -> Bool
143
+ pFoldl' :: Int -> [Int ] -> Property
144
144
pFoldl' z0 = foldl'Set (+) z0 `eq` S. foldl' (+) z0
145
145
146
146
foldl'Set :: (a -> b -> a ) -> a -> Set. Set b -> a
@@ -149,13 +149,13 @@ foldl'Set = Set.foldl'
149
149
------------------------------------------------------------------------
150
150
-- ** Filter
151
151
152
- pFilter :: [Key ] -> Bool
152
+ pFilter :: [Key ] -> Property
153
153
pFilter = Set. filter odd `eq_` S. filter odd
154
154
155
155
------------------------------------------------------------------------
156
156
-- ** Conversions
157
157
158
- pToList :: [Key ] -> Bool
158
+ pToList :: [Key ] -> Property
159
159
pToList = Set. toAscList `eq` toAscList
160
160
161
161
------------------------------------------------------------------------
@@ -211,22 +211,21 @@ type Model a = Set.Set a
211
211
212
212
-- | Check that a function operating on a 'HashMap' is equivalent to
213
213
-- one operating on a 'Model'.
214
- eq :: (Eq a , Hashable a , Ord a , Eq b )
214
+ eq :: (Eq a , Hashable a , Ord a , Show a , Eq b , Show b )
215
215
=> (Model a -> b ) -- ^ Function that modifies a 'Model' in the same
216
216
-- way
217
217
-> (S. HashSet a -> b ) -- ^ Function that modified a 'HashSet'
218
218
-> [a ] -- ^ Initial content of the 'HashSet' and 'Model'
219
- -> Bool -- ^ True if the functions are equivalent
220
- eq f g xs = g ( S . fromList xs) == f ( Set . fromList xs)
219
+ -> Property
220
+ eq f g xs = f ( Set . fromList xs) === g ( S . fromList xs)
221
221
222
- eq_ :: (Eq a , Hashable a , Ord a )
222
+ eq_ :: (Eq a , Hashable a , Ord a , Show a )
223
223
=> (Model a -> Model a ) -- ^ Function that modifies a 'Model'
224
224
-> (S. HashSet a -> S. HashSet a ) -- ^ Function that modified a
225
225
-- 'HashSet' in the same way
226
226
-> [a ] -- ^ Initial content of the 'HashSet'
227
227
-- and 'Model'
228
- -> Bool -- ^ True if the functions are
229
- -- equivalent
228
+ -> Property
230
229
eq_ f g = (Set. toAscList . f) `eq` (toAscList . g)
231
230
232
231
------------------------------------------------------------------------
0 commit comments