-- | Stability: provisional
module Test.Hspec.Core.QuickCheck (
  modifyArgs
, modifyMaxSuccess
, modifyMaxDiscardRatio
, modifyMaxSize
, modifyMaxShrinks
) where

import           Prelude ()
import           Test.Hspec.Core.Compat

import           Test.QuickCheck
import           Test.Hspec.Core.Spec

-- | Use a modified `maxSuccess` for given spec.
modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxSuccess = (Args -> Args) -> SpecWith a -> SpecWith a
forall a. (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs ((Args -> Args) -> SpecWith a -> SpecWith a)
-> ((Int -> Int) -> Args -> Args)
-> (Int -> Int)
-> SpecWith a
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int) -> Args -> Args
modify
  where
    modify :: (Int -> Int) -> Args -> Args
    modify :: (Int -> Int) -> Args -> Args
modify Int -> Int
f Args
args = Args
args {maxSuccess :: Int
maxSuccess = Int -> Int
f (Args -> Int
maxSuccess Args
args)}

-- | Use a modified `maxDiscardRatio` for given spec.
modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxDiscardRatio = (Args -> Args) -> SpecWith a -> SpecWith a
forall a. (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs ((Args -> Args) -> SpecWith a -> SpecWith a)
-> ((Int -> Int) -> Args -> Args)
-> (Int -> Int)
-> SpecWith a
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int) -> Args -> Args
modify
  where
    modify :: (Int -> Int) -> Args -> Args
    modify :: (Int -> Int) -> Args -> Args
modify Int -> Int
f Args
args = Args
args {maxDiscardRatio :: Int
maxDiscardRatio = Int -> Int
f (Args -> Int
maxDiscardRatio Args
args)}

-- | Use a modified `maxSize` for given spec.
modifyMaxSize :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxSize :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxSize = (Args -> Args) -> SpecWith a -> SpecWith a
forall a. (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs ((Args -> Args) -> SpecWith a -> SpecWith a)
-> ((Int -> Int) -> Args -> Args)
-> (Int -> Int)
-> SpecWith a
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int) -> Args -> Args
modify
  where
    modify :: (Int -> Int) -> Args -> Args
    modify :: (Int -> Int) -> Args -> Args
modify Int -> Int
f Args
args = Args
args {maxSize :: Int
maxSize = Int -> Int
f (Args -> Int
maxSize Args
args)}

-- | Use a modified `maxShrinks` for given spec.
modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxShrinks = (Args -> Args) -> SpecWith a -> SpecWith a
forall a. (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs ((Args -> Args) -> SpecWith a -> SpecWith a)
-> ((Int -> Int) -> Args -> Args)
-> (Int -> Int)
-> SpecWith a
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int) -> Args -> Args
modify
  where
    modify :: (Int -> Int) -> Args -> Args
    modify :: (Int -> Int) -> Args -> Args
modify Int -> Int
f Args
args = Args
args {maxShrinks :: Int
maxShrinks = Int -> Int
f (Args -> Int
maxShrinks Args
args)}

-- | Use modified `Args` for given spec.
modifyArgs :: (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs :: (Args -> Args) -> SpecWith a -> SpecWith a
modifyArgs = (Params -> Params) -> SpecWith a -> SpecWith a
forall a. (Params -> Params) -> SpecWith a -> SpecWith a
modifyParams ((Params -> Params) -> SpecWith a -> SpecWith a)
-> ((Args -> Args) -> Params -> Params)
-> (Args -> Args)
-> SpecWith a
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Args -> Args) -> Params -> Params
modify
  where
    modify :: (Args -> Args) -> Params -> Params
    modify :: (Args -> Args) -> Params -> Params
modify Args -> Args
f Params
p = Params
p {paramsQuickCheckArgs :: Args
paramsQuickCheckArgs = Args -> Args
f (Params -> Args
paramsQuickCheckArgs Params
p)}