This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ fromZipper (Cons x ctx) tree =
245
245
246
246
data KickUp k v = KickUp (Map k v ) k v (Map k v )
247
247
248
- -- | Insert a key/value pair into a map
248
+ -- | Insert or replace a key/value pair in a map
249
249
insert :: forall k v . Ord k => k -> v -> Map k v -> Map k v
250
250
insert = down Nil
251
251
where
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ lookup = runFn4 _lookup Nothing Just
164
164
member :: forall a . String -> StrMap a -> Boolean
165
165
member = runFn4 _lookup false (const true )
166
166
167
- -- | Insert a key and value into a map
167
+ -- | Insert or replace a key/ value pair in a map
168
168
insert :: forall a . String -> a -> StrMap a -> StrMap a
169
169
insert k v = mutate (\s -> void $ SM .poke s k v)
170
170
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ mapTests = do
121
121
quickCheck $ \k v -> M .lookup (smallKey k) (M .insert k v M .empty) == Just (number v)
122
122
<?> (" k: " <> show k <> " , v: " <> show v)
123
123
124
+ log " Test inserting two values with same key"
125
+ quickCheck $ \k v1 v2 ->
126
+ M .lookup (smallKey k) (M .insert k v2 (M .insert k v1 M .empty)) == Just (number v2)
127
+
124
128
log " Test delete after inserting"
125
129
quickCheck $ \k v -> M .isEmpty (M .delete (smallKey k) (M .insert k (number v) M .empty))
126
130
<?> (" k: " <> show k <> " , v: " <> show v)
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ strMapTests = do
59
59
quickCheck $ \k v -> M .lookup k (M .insert k v M .empty) == Just (number v)
60
60
<?> (" k: " <> show k <> " , v: " <> show v)
61
61
62
+ log " Test inserting two values with same key"
63
+ quickCheck $ \k v1 v2 ->
64
+ M .lookup k (M .insert k v2 (M .insert k v1 M .empty)) == Just (number v2)
65
+
62
66
log " Test delete after inserting"
63
67
quickCheck $ \k v -> M .isEmpty (M .delete k (M .insert k (number v) M .empty))
64
68
<?> (" k: " <> show k <> " , v: " <> show v)
You can’t perform that action at this time.
0 commit comments