Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/Properties/HashMapLazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ tests =
\(x :: HMKI) y -> HM.isSubmapOf x (HM.union x y)
, testProperty "m1\\m2 ⊆ m1" $
\(m1 :: HMKI) (m2 :: HMKI) -> HM.isSubmapOf (HM.difference m1 m2) m1
, testProperty "m1 ∩ m2 ≠ ∅ ⇒ m1 ⊈ m1\\m2 " $
, testProperty "m1 ∩ m2 ≠ ∅ ⇒ m1 ⊈ m1\\m2 " $ QC.withMaxSize 200 $
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we even have this property?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. It seems to be the same idea as the m ⊈ delete k m test below. I've deleted this test a few other ones in #518.

\(m1 :: HMKI) (m2 :: HMKI) ->
not (HM.null (HM.intersection m1 m2)) ==>
not (HM.isSubmapOf m1 (HM.difference m1 m2))
Expand Down Expand Up @@ -303,9 +303,9 @@ tests =
\(Fn3 f) (x :: HMKI) y -> isValid (HM.unionWithKey f x y)
]
, testGroup "unions"
[ testProperty "model" $
[ testProperty "model" $ QC.withMaxSize 200 $
\(ms :: [HMKI]) -> toOrdMap (HM.unions ms) === M.unions (map toOrdMap ms)
, testProperty "valid" $
, testProperty "valid" $ QC.withMaxSize 200 $
\(ms :: [HMKI]) -> isValid (HM.unions ms)
]
, testGroup "difference"
Expand All @@ -323,28 +323,28 @@ tests =
\(Fn2 f) (x :: HMK A) (y :: HMK B) -> isValid (HM.differenceWith f x y)
]
, testGroup "intersection"
[ testProperty "model" $
[ testProperty "model" $ QC.withMaxSize 200 $
\(x :: HMKI) (y :: HMKI) ->
toOrdMap (HM.intersection x y) === M.intersection (toOrdMap x) (toOrdMap y)
, testProperty "valid" $
, testProperty "valid" $ QC.withMaxSize 200 $
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this test take a long time? I'd much rather have a slightly more complex valid than weaken validity tests. Also, should we reuse the maps generated for the previous test? .&&. will let us know which part failed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dug through the validity code, and it all looks like it should be fast. That makes me wonder why this test would take a long time

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I was misled when I tried to run these tests with stack test --coverage and inflated --quickcheck-max-size. Without the HPC options, the runtimes are entirely unremarkable.

\(x :: HMKI) (y :: HMKI) ->
isValid (HM.intersection x y)
]
, testGroup "intersectionWith"
[ testProperty "model" $
[ testProperty "model" $ QC.withMaxSize 200 $
\(Fn2 f :: Fun (A, B) C) (x :: HMK A) (y :: HMK B) ->
toOrdMap (HM.intersectionWith f x y) === M.intersectionWith f (toOrdMap x) (toOrdMap y)
, testProperty "valid" $
, testProperty "valid" $ QC.withMaxSize 200 $
\(Fn2 f :: Fun (A, B) C) (x :: HMK A) (y :: HMK B) ->
isValid (HM.intersectionWith f x y)
]
, testGroup "intersectionWithKey"
[ testProperty "model" $
[ testProperty "model" $ QC.withMaxSize 200 $
\(Fn3 f :: Fun (Key, A, B) C) (x :: HMK A) (y :: HMK B) ->
toOrdMap (HM.intersectionWithKey f x y)
===
M.intersectionWithKey f (toOrdMap x) (toOrdMap y)
, testProperty "valid" $
, testProperty "valid" $ QC.withMaxSize 200 $
\(Fn3 f :: Fun (Key, A, B) C) (x :: HMK A) (y :: HMK B) ->
isValid (HM.intersectionWithKey f x y)
]
Expand All @@ -360,12 +360,12 @@ tests =
\(Fn f :: Fun A B) (m :: HMK A) -> isValid (HM.map f m)
]
, testGroup "traverseWithKey"
[ testProperty "model" $ QC.mapSize (\s -> s `div` 8) $
[ testProperty "model" $ QC.withMaxSize 22 $
\(x :: HMKI) ->
let f k v = [keyToInt k + v + 1, keyToInt k + v + 2]
ys = HM.traverseWithKey f x
in List.sort (fmap toOrdMap ys) === List.sort (M.traverseWithKey f (toOrdMap x))
, testProperty "valid" $ QC.mapSize (\s -> s `div` 8) $
, testProperty "valid" $ QC.withMaxSize 22 $
\(x :: HMKI) ->
let f k v = [keyToInt k + v + 1, keyToInt k + v + 2]
ys = HM.traverseWithKey f x
Expand Down