Skip to content

Commit e09db27

Browse files
committed
check maps are well constructed in fromSetA action order props
1 parent affadb3 commit e09db27

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

containers-tests/tests/intmap-properties.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,12 +1705,16 @@ prop_fromSet keys funF =
17051705

17061706
prop_fromSetA_action_order :: [Int] -> Fun Int A -> Property
17071707
prop_fromSetA_action_order keys funF =
1708-
let iSet = IntSet.fromList keys
1708+
let set = IntSet.fromList keys
1709+
setList = IntSet.toList set
17091710
f = apply funF
17101711
action = \k ->
17111712
let v = f k
17121713
in tell [v] $> v
1713-
in execWriter (fromSetA action iSet) === List.map f (IntSet.toList iSet)
1714+
(writtenMap, writtenOutput) = runWriter (fromSetA action set)
1715+
in
1716+
writtenOutput === List.map f setList .&&.
1717+
toList writtenMap === fmap (id &&& f) setList
17141718

17151719
newtype Identity a = Identity a
17161720
deriving (Eq, Show)

containers-tests/tests/map-properties.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,12 +1699,16 @@ prop_fromSet keys funF =
16991699

17001700
prop_fromSetA_action_order :: [OrdA] -> Fun OrdA B -> Property
17011701
prop_fromSetA_action_order keys funF =
1702-
let iSet = Set.fromList keys
1702+
let set = Set.fromList keys
1703+
setList = Set.toList set
17031704
f = apply funF
17041705
action = \k ->
17051706
let v = f k
17061707
in tell [v] $> v
1707-
in execWriter (fromSetA action iSet) === List.map f (Set.toList iSet)
1708+
(writtenMap, writtenOutput) = runWriter (fromSetA action set)
1709+
in
1710+
writtenOutput === List.map f setList .&&.
1711+
toList writtenMap === fmap (id &&& f) setList
17081712

17091713
prop_fromArgSet :: [(OrdA, B)] -> Property
17101714
prop_fromArgSet ys =

0 commit comments

Comments
 (0)