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
{{ message }}
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
instancearbMap :: (Eqk, Ordk, Arbitraryk, Arbitraryv) =>Arbitrary (M.Mapkv) where
19
-
arbitrary = M.fromList <$> arbitrary
18
+
newtypeTestMapkv = TestMap (M.Mapkv)
20
19
21
-
instancearbitraryList :: (Arbitrarya) =>Arbitrary (Lista) where
22
-
arbitrary = toList <$> (arbitrary::Gen (Arraya))
20
+
instancearbTestMap :: (Eqk, Ordk, Arbitraryk, Arbitraryv) =>Arbitrary (TestMapkv) where
21
+
arbitrary = TestMap <<< M.fromList <$> arbitrary
23
22
24
23
dataSmallKey = A|B|C|D|E|F|G|H|I|J
25
24
@@ -133,7 +132,7 @@ mapTests = do
133
132
<?> ("k1: " ++ show k1 ++ ", v1: " ++ show v1 ++ ", k2: " ++ show k2 ++ ", v2: " ++ show v2)
134
133
135
134
log "Check balance property"
136
-
quickCheck' 5000 $ \instrs ->
135
+
quickCheck' 1000 $ \instrs ->
137
136
let
138
137
tree::M.MapSmallKeyInt
139
138
tree = runInstructions instrs M.empty
@@ -146,7 +145,7 @@ mapTests = do
146
145
quickCheck $ \k v ->M.lookup (k ::SmallKey) (M.singleton k (v ::Int)) == Just v
147
146
148
147
log "Random lookup"
149
-
quickCheck' 5000 $ \instrs k v ->
148
+
quickCheck' 1000 $ \instrs k v ->
150
149
let
151
150
tree::M.MapSmallKeyInt
152
151
tree = M.insert k v (runInstructions instrs M.empty)
@@ -160,7 +159,7 @@ mapTests = do
160
159
in f (f arr) == f (arr ::List (TupleSmallKeyInt)) <?> show arr
161
160
162
161
log "fromList . toList = id"
163
-
quickCheck $ \m->let f m = M.fromList (M.toList m) in
162
+
quickCheck $ \(TestMap m)->let f m = M.fromList (M.toList m) in
164
163
M.toList (f m) == M.toList (m ::M.MapSmallKeyInt) <?> show m
165
164
166
165
log "fromListWith const = fromList"
@@ -176,26 +175,27 @@ mapTests = do
176
175
M.fromListWith (<>) arr == f (arr ::List (TupleStringString)) <?> show arr
177
176
178
177
log "Lookup from union"
179
-
quickCheck $ \m1 m2 k ->M.lookup (smallKey k) (M.union m1 m2) == (caseM.lookup k m1 of
180
-
Nothing->M.lookup k m2
181
-
Just v ->Just (number v)) <?> ("m1: " ++ show m1 ++ ", m2: " ++ show m2 ++ ", k: " ++ show k ++ ", v1: " ++ show (M.lookup k m1) ++ ", v2: " ++ show (M.lookup k m2) ++ ", union: " ++ show (M.union m1 m2))
178
+
quickCheck $ \(TestMap m1) (TestMap m2) k ->
179
+
M.lookup (smallKey k) (M.union m1 m2) == (caseM.lookup k m1 of
180
+
Nothing->M.lookup k m2
181
+
Just v ->Just (number v)) <?> ("m1: " ++ show m1 ++ ", m2: " ++ show m2 ++ ", k: " ++ show k ++ ", v1: " ++ show (M.lookup k m1) ++ ", v2: " ++ show (M.lookup k m2) ++ ", union: " ++ show (M.union m1 m2))
quickCheck $ \k v ->M.lookup k (M.singleton k (v ::Int)) == Just v
75
74
76
75
log "Random lookup"
77
-
quickCheck' 5000 $ \instrs k v ->
76
+
quickCheck' 1000 $ \instrs k v ->
78
77
let
79
78
tree::M.StrMapInt
80
79
tree = M.insert k v (runInstructions instrs M.empty)
@@ -88,8 +87,9 @@ strMapTests = do
88
87
in f (f arr) == f (arr ::List (TupleStringInt)) <?> show arr
89
88
90
89
log "fromList . toList = id"
91
-
quickCheck $ \m ->let f m = M.fromList (M.toList m) in
92
-
M.toList (f m) == M.toList (m ::M.StrMapInt) <?> show m
90
+
quickCheck $ \(TestStrMap m) ->
91
+
let f m = M.fromList (M.toList m) in
92
+
M.toList (f m) == M.toList (m ::M.StrMapInt) <?> show m
93
93
94
94
log "fromListWith const = fromList"
95
95
quickCheck $ \arr ->M.fromListWith const arr ==
@@ -104,12 +104,14 @@ strMapTests = do
104
104
M.fromListWith (<>) arr == f (arr ::List (TupleStringString)) <?> show arr
105
105
106
106
log "Lookup from union"
107
-
quickCheck $ \m1 m2 k ->M.lookup k (M.union m1 m2) == (caseM.lookup k m1 of
108
-
Nothing->M.lookup k m2
109
-
Just v ->Just (number v)) <?> ("m1: " ++ show m1 ++ ", m2: " ++ show m2 ++ ", k: " ++ show k ++ ", v1: " ++ show (M.lookup k m1) ++ ", v2: " ++ show (M.lookup k m2) ++ ", union: " ++ show (M.union m1 m2))
107
+
quickCheck $ \(TestStrMap m1) (TestStrMap m2) k ->
108
+
M.lookup k (M.union m1 m2) == (caseM.lookup k m1 of
109
+
Nothing->M.lookup k m2
110
+
Just v ->Just (number v)) <?> ("m1: " ++ show m1 ++ ", m2: " ++ show m2 ++ ", k: " ++ show k ++ ", v1: " ++ show (M.lookup k m1) ++ ", v2: " ++ show (M.lookup k m2) ++ ", union: " ++ show (M.union m1 m2))
0 commit comments