{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Test.Syd.Modify
(
modifyMaxSuccess,
modifyMaxDiscardRatio,
modifyMaxSize,
modifyMaxShrinks,
modifyRunSettings,
TestRunSettings (..),
sequential,
parallel,
withParallelism,
Parallelism (..),
randomiseExecutionOrder,
doNotRandomiseExecutionOrder,
withExecutionOrderRandomisation,
ExecutionOrderRandomisation (..),
)
where
import Control.Monad.RWS.Strict
import Test.QuickCheck.IO ()
import Test.Syd.Def
import Test.Syd.Run
import Test.Syd.SpecDef
modifyRunSettings :: (TestRunSettings -> TestRunSettings) -> TestDefM a b c -> TestDefM a b c
modifyRunSettings :: (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
modifyRunSettings = (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local
modifyMaxSuccess :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxSuccess :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxSuccess Int -> Int
func = (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
(TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
modifyRunSettings ((TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c)
-> (TestRunSettings -> TestRunSettings)
-> TestDefM a b c
-> TestDefM a b c
forall a b. (a -> b) -> a -> b
$ \TestRunSettings
trs -> TestRunSettings
trs {testRunSettingMaxSuccess :: Int
testRunSettingMaxSuccess = Int -> Int
func (TestRunSettings -> Int
testRunSettingMaxSuccess TestRunSettings
trs)}
modifyMaxDiscardRatio :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxDiscardRatio :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxDiscardRatio Int -> Int
func = (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
(TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
modifyRunSettings ((TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c)
-> (TestRunSettings -> TestRunSettings)
-> TestDefM a b c
-> TestDefM a b c
forall a b. (a -> b) -> a -> b
$ \TestRunSettings
trs -> TestRunSettings
trs {testRunSettingMaxDiscardRatio :: Int
testRunSettingMaxDiscardRatio = Int -> Int
func (TestRunSettings -> Int
testRunSettingMaxDiscardRatio TestRunSettings
trs)}
modifyMaxSize :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxSize :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxSize Int -> Int
func = (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
(TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
modifyRunSettings ((TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c)
-> (TestRunSettings -> TestRunSettings)
-> TestDefM a b c
-> TestDefM a b c
forall a b. (a -> b) -> a -> b
$ \TestRunSettings
trs -> TestRunSettings
trs {testRunSettingMaxSize :: Int
testRunSettingMaxSize = Int -> Int
func (TestRunSettings -> Int
testRunSettingMaxSize TestRunSettings
trs)}
modifyMaxShrinks :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxShrinks :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
modifyMaxShrinks Int -> Int
func = (TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
(TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c
modifyRunSettings ((TestRunSettings -> TestRunSettings)
-> TestDefM a b c -> TestDefM a b c)
-> (TestRunSettings -> TestRunSettings)
-> TestDefM a b c
-> TestDefM a b c
forall a b. (a -> b) -> a -> b
$ \TestRunSettings
trs -> TestRunSettings
trs {testRunSettingMaxShrinks :: Int
testRunSettingMaxShrinks = Int -> Int
func (TestRunSettings -> Int
testRunSettingMaxShrinks TestRunSettings
trs)}
sequential :: TestDefM a b c -> TestDefM a b c
sequential :: TestDefM a b c -> TestDefM a b c
sequential = Parallelism -> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
Parallelism -> TestDefM a b c -> TestDefM a b c
withParallelism Parallelism
Sequential
parallel :: TestDefM a b c -> TestDefM a b c
parallel :: TestDefM a b c -> TestDefM a b c
parallel = Parallelism -> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
Parallelism -> TestDefM a b c -> TestDefM a b c
withParallelism Parallelism
Parallel
withParallelism :: Parallelism -> TestDefM a b c -> TestDefM a b c
withParallelism :: Parallelism -> TestDefM a b c -> TestDefM a b c
withParallelism Parallelism
p = ([SpecDefTree a b ()] -> [SpecDefTree a b ()])
-> TestDefM a b c -> TestDefM a b c
forall w (m :: * -> *) a. MonadWriter w m => (w -> w) -> m a -> m a
censor ((SpecDefTree a b () -> [SpecDefTree a b ()] -> [SpecDefTree a b ()]
forall a. a -> [a] -> [a]
: []) (SpecDefTree a b () -> [SpecDefTree a b ()])
-> ([SpecDefTree a b ()] -> SpecDefTree a b ())
-> [SpecDefTree a b ()]
-> [SpecDefTree a b ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parallelism -> [SpecDefTree a b ()] -> SpecDefTree a b ()
forall (outers :: [*]) inner extra.
Parallelism
-> SpecDefForest outers inner extra
-> SpecDefTree outers inner extra
DefParallelismNode Parallelism
p)
randomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
randomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
randomiseExecutionOrder = ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
withExecutionOrderRandomisation ExecutionOrderRandomisation
RandomiseExecutionOrder
doNotRandomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
doNotRandomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
doNotRandomiseExecutionOrder = ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
forall (a :: [*]) b c.
ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
withExecutionOrderRandomisation ExecutionOrderRandomisation
DoNotRandomiseExecutionOrder
withExecutionOrderRandomisation :: ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
withExecutionOrderRandomisation :: ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
withExecutionOrderRandomisation ExecutionOrderRandomisation
p = ([SpecDefTree a b ()] -> [SpecDefTree a b ()])
-> TestDefM a b c -> TestDefM a b c
forall w (m :: * -> *) a. MonadWriter w m => (w -> w) -> m a -> m a
censor ((SpecDefTree a b () -> [SpecDefTree a b ()] -> [SpecDefTree a b ()]
forall a. a -> [a] -> [a]
: []) (SpecDefTree a b () -> [SpecDefTree a b ()])
-> ([SpecDefTree a b ()] -> SpecDefTree a b ())
-> [SpecDefTree a b ()]
-> [SpecDefTree a b ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExecutionOrderRandomisation
-> [SpecDefTree a b ()] -> SpecDefTree a b ()
forall (outers :: [*]) inner extra.
ExecutionOrderRandomisation
-> SpecDefForest outers inner extra
-> SpecDefTree outers inner extra
DefRandomisationNode ExecutionOrderRandomisation
p)