Skip to content

Commit 6a438d2

Browse files
committed
Add test for intersection
1 parent 330c180 commit 6a438d2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Data/HashMap/Internal.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ module Data.HashMap.Internal
110110

111111
-- * Debugging
112112
, valid
113-
, Validity
114-
, Error
113+
, Validity(..)
114+
, Error(..)
115115
, SubHash
116-
, SubHashPath
116+
, SubHashPath(..)
117117

118118
-- ** Internals used by the strict version
119119
, Hash

tests/Properties/HashMapLazy.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ import Test.Tasty (TestTree, testGroup)
2929
import Test.Tasty.QuickCheck (testProperty)
3030
import Util.Key (Key, keyToInt)
3131

32-
import qualified Data.Foldable as Foldable
33-
import qualified Data.List as List
32+
import qualified Data.Foldable as Foldable
33+
import qualified Data.HashMap.Internal as HMI
34+
import qualified Data.List as List
3435

3536
#if defined(STRICT)
3637
import Data.HashMap.Strict (HashMap)
@@ -319,6 +320,9 @@ pIntersection xs ys =
319320
`eq_` HM.intersection (HM.fromList xs)
320321
$ ys
321322

323+
pIntersectionValid :: HashMap Key () -> HashMap Key () -> Property
324+
pIntersectionValid x y = HMI.valid (HM.intersection x y) === HMI.Valid
325+
322326
pIntersectionWith :: [(Key, Int)] -> [(Key, Int)] -> Property
323327
pIntersectionWith xs ys = M.intersectionWith (-) (M.fromList xs) `eq_`
324328
HM.intersectionWith (-) (HM.fromList xs) $ ys
@@ -529,6 +533,7 @@ tests =
529533
[ testProperty "difference" pDifference
530534
, testProperty "differenceWith" pDifferenceWith
531535
, testProperty "intersection" pIntersection
536+
, testProperty "intersection produces valid HashMap" pIntersectionValid
532537
, testProperty "intersectionWith" pIntersectionWith
533538
, testProperty "intersectionWithKey" pIntersectionWithKey
534539
]

0 commit comments

Comments
 (0)