Skip to content

Commit a4693f1

Browse files
committed
Update key generation in IntMap and IntSet tests
Some IntSet and IntMap functions need to check whether the top-level split is at the sign bit and handle it specially. Generating sets and maps with all negative or non-negative keys makes it more likely to cover all cases in property tests.
1 parent 9920666 commit a4693f1

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

containers-tests/tests/intmap-properties.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ main = defaultMain $ testGroup "intmap-properties"
272272
--------------------------------------------------------------------}
273273

274274
instance Arbitrary a => Arbitrary (IntMap a) where
275-
arbitrary = oneof [go arbitrary, go (getLarge <$> arbitrary)]
275+
arbitrary = oneof
276+
[ go arbitrary
277+
, go (getLarge <$> arbitrary)
278+
, go (getNonNegative <$> arbitrary)
279+
, go (getNegative <$> arbitrary)
280+
]
276281
where
277282
go kgen = fromList <$> listOf ((,) <$> kgen <*> arbitrary)
278283
shrink = fmap fromList . shrink . toAscList

containers-tests/tests/intset-properties.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ test_compareSize = do
151151
Arbitrary, reasonably balanced trees
152152
--------------------------------------------------------------------}
153153
instance Arbitrary IntSet where
154-
arbitrary = fromList <$> oneof [arbitrary, fmap (fmap getLarge) arbitrary]
154+
arbitrary = fromList <$> oneof
155+
[ arbitrary
156+
, listOf (getLarge <$> arbitrary)
157+
, listOf (getNonNegative <$> arbitrary)
158+
, listOf (getNegative <$> arbitrary)
159+
]
155160
shrink = fmap fromList . shrink . toAscList
156161

157162
{--------------------------------------------------------------------

0 commit comments

Comments
 (0)