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 =
245245
246246data KickUp k v = KickUp (Map k v ) k v (Map k v )
247247
248- -- | Insert a key/value pair into a map
248+ -- | Insert or replace a key/value pair in a map
249249insert :: forall k v . Ord k => k -> v -> Map k v -> Map k v
250250insert = down Nil
251251 where
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ lookup = runFn4 _lookup Nothing Just
164164member :: forall a . String -> StrMap a -> Boolean
165165member = runFn4 _lookup false (const true )
166166
167- -- | Insert a key and value into a map
167+ -- | Insert or replace a key/ value pair in a map
168168insert :: forall a . String -> a -> StrMap a -> StrMap a
169169insert k v = mutate (\s -> void $ SM .poke s k v)
170170
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ mapTests = do
121121 quickCheck $ \k v -> M .lookup (smallKey k) (M .insert k v M .empty) == Just (number v)
122122 <?> (" k: " <> show k <> " , v: " <> show v)
123123
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+
124128 log " Test delete after inserting"
125129 quickCheck $ \k v -> M .isEmpty (M .delete (smallKey k) (M .insert k (number v) M .empty))
126130 <?> (" k: " <> show k <> " , v: " <> show v)
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ strMapTests = do
5959 quickCheck $ \k v -> M .lookup k (M .insert k v M .empty) == Just (number v)
6060 <?> (" k: " <> show k <> " , v: " <> show v)
6161
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+
6266 log " Test delete after inserting"
6367 quickCheck $ \k v -> M .isEmpty (M .delete k (M .insert k (number v) M .empty))
6468 <?> (" k: " <> show k <> " , v: " <> show v)
You can’t perform that action at this time.
0 commit comments