1-- | Stability: provisional
2module Test.Hspec.Core.QuickCheck (
3  modifyArgs
4, modifyMaxSuccess
5, modifyMaxDiscardRatio
6, modifyMaxSize
7, modifyMaxShrinks
8) where
9
10import           Test.QuickCheck
11import           Test.Hspec.Core.Spec
12
13-- | Use a modified `maxSuccess` for given spec.
14modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a
15modifyMaxSuccess = modifyArgs . modify
16  where
17    modify :: (Int -> Int) -> Args -> Args
18    modify f args = args {maxSuccess = f (maxSuccess args)}
19
20-- | Use a modified `maxDiscardRatio` for given spec.
21modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a
22modifyMaxDiscardRatio = modifyArgs . modify
23  where
24    modify :: (Int -> Int) -> Args -> Args
25    modify f args = args {maxDiscardRatio = f (maxDiscardRatio args)}
26
27-- | Use a modified `maxSize` for given spec.
28modifyMaxSize :: (Int -> Int) -> SpecWith a -> SpecWith a
29modifyMaxSize = modifyArgs . modify
30  where
31    modify :: (Int -> Int) -> Args -> Args
32    modify f args = args {maxSize = f (maxSize args)}
33
34-- | Use a modified `maxShrinks` for given spec.
35modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a
36modifyMaxShrinks = modifyArgs . modify
37  where
38    modify :: (Int -> Int) -> Args -> Args
39    modify f args = args {maxShrinks = f (maxShrinks args)}
40
41-- | Use modified `Args` for given spec.
42modifyArgs :: (Args -> Args) -> SpecWith a -> SpecWith a
43modifyArgs = modifyParams . modify
44  where
45    modify :: (Args -> Args) -> Params -> Params
46    modify f p = p {paramsQuickCheckArgs = f (paramsQuickCheckArgs p)}
47