-- | This module allows to use QuickCheck properties in tasty.
{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
module Test.Tasty.QuickCheck
  ( testProperty
  , testProperties
  , QuickCheckTests(..)
  , QuickCheckReplay(..)
  , QuickCheckShowReplay(..)
  , QuickCheckMaxSize(..)
  , QuickCheckMaxRatio(..)
  , QuickCheckVerbose(..)
  , module Test.QuickCheck
    -- * Internal
    -- | If you are building a test suite, you don't need these functions.
    --
    -- They may be used by other tasty add-on packages (such as tasty-hspec).
  , QC(..)
  , optionSetToArgs
  ) where

import Test.Tasty ( testGroup )
import Test.Tasty.Providers
import Test.Tasty.Options
import qualified Test.QuickCheck as QC
import Test.Tasty.Runners (formatMessage)
import Test.QuickCheck hiding -- for re-export
  ( quickCheck
  , Args(..)
  , Result
  , stdArgs
  , quickCheckWith
  , quickCheckWithResult
  , quickCheckResult
  , verboseCheck
  , verboseCheckWith
  , verboseCheckWithResult
  , verboseCheckResult
  , verbose
  -- Template Haskell functions
#if MIN_VERSION_QuickCheck(2,11,0)
  , allProperties
#endif
  , forAllProperties
  , quickCheckAll
  , verboseCheckAll
  )

import Data.Proxy (Proxy(..))
import Data.Typeable (Typeable)
import Data.List
import Text.Printf
import Test.QuickCheck.Random (mkQCGen)
import Options.Applicative (metavar)
import System.Random (getStdRandom, randomR)
#if !MIN_VERSION_base(4,9,0)
import Control.Applicative
import Data.Monoid
#endif

newtype QC = QC QC.Property
  deriving Typeable

-- | Create a 'Test' for a QuickCheck 'QC.Testable' property
testProperty :: QC.Testable a => TestName -> a -> TestTree
testProperty :: TestName -> a -> TestTree
testProperty TestName
name a
prop = TestName -> QC -> TestTree
forall t. IsTest t => TestName -> t -> TestTree
singleTest TestName
name (QC -> TestTree) -> QC -> TestTree
forall a b. (a -> b) -> a -> b
$ Property -> QC
QC (Property -> QC) -> Property -> QC
forall a b. (a -> b) -> a -> b
$ a -> Property
forall prop. Testable prop => prop -> Property
QC.property a
prop

-- | Create a test from a list of QuickCheck properties. To be used
-- with 'Test.QuickCheck.allProperties'. E.g.
--
-- >tests :: TestTree
-- >tests = testProperties "Foo" $allProperties
testProperties :: TestName -> [(String, Property)] -> TestTree
testProperties :: TestName -> [(TestName, Property)] -> TestTree
testProperties TestName
name = TestName -> [TestTree] -> TestTree
testGroup TestName
name ([TestTree] -> TestTree)
-> ([(TestName, Property)] -> [TestTree])
-> [(TestName, Property)]
-> TestTree
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TestName, Property) -> TestTree)
-> [(TestName, Property)] -> [TestTree]
forall a b. (a -> b) -> [a] -> [b]
map ((TestName -> Property -> TestTree)
-> (TestName, Property) -> TestTree
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry TestName -> Property -> TestTree
forall a. Testable a => TestName -> a -> TestTree
testProperty)

-- | Number of test cases for QuickCheck to generate
newtype QuickCheckTests = QuickCheckTests Int
  deriving (Integer -> QuickCheckTests
QuickCheckTests -> QuickCheckTests
QuickCheckTests -> QuickCheckTests -> QuickCheckTests
(QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests)
-> (Integer -> QuickCheckTests)
-> Num QuickCheckTests
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> QuickCheckTests
$cfromInteger :: Integer -> QuickCheckTests
signum :: QuickCheckTests -> QuickCheckTests
$csignum :: QuickCheckTests -> QuickCheckTests
abs :: QuickCheckTests -> QuickCheckTests
$cabs :: QuickCheckTests -> QuickCheckTests
negate :: QuickCheckTests -> QuickCheckTests
$cnegate :: QuickCheckTests -> QuickCheckTests
* :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$c* :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
- :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$c- :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
+ :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$c+ :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
Num, Eq QuickCheckTests
Eq QuickCheckTests
-> (QuickCheckTests -> QuickCheckTests -> Ordering)
-> (QuickCheckTests -> QuickCheckTests -> Bool)
-> (QuickCheckTests -> QuickCheckTests -> Bool)
-> (QuickCheckTests -> QuickCheckTests -> Bool)
-> (QuickCheckTests -> QuickCheckTests -> Bool)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> Ord QuickCheckTests
QuickCheckTests -> QuickCheckTests -> Bool
QuickCheckTests -> QuickCheckTests -> Ordering
QuickCheckTests -> QuickCheckTests -> QuickCheckTests
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cmin :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
max :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cmax :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
>= :: QuickCheckTests -> QuickCheckTests -> Bool
$c>= :: QuickCheckTests -> QuickCheckTests -> Bool
> :: QuickCheckTests -> QuickCheckTests -> Bool
$c> :: QuickCheckTests -> QuickCheckTests -> Bool
<= :: QuickCheckTests -> QuickCheckTests -> Bool
$c<= :: QuickCheckTests -> QuickCheckTests -> Bool
< :: QuickCheckTests -> QuickCheckTests -> Bool
$c< :: QuickCheckTests -> QuickCheckTests -> Bool
compare :: QuickCheckTests -> QuickCheckTests -> Ordering
$ccompare :: QuickCheckTests -> QuickCheckTests -> Ordering
$cp1Ord :: Eq QuickCheckTests
Ord, QuickCheckTests -> QuickCheckTests -> Bool
(QuickCheckTests -> QuickCheckTests -> Bool)
-> (QuickCheckTests -> QuickCheckTests -> Bool)
-> Eq QuickCheckTests
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuickCheckTests -> QuickCheckTests -> Bool
$c/= :: QuickCheckTests -> QuickCheckTests -> Bool
== :: QuickCheckTests -> QuickCheckTests -> Bool
$c== :: QuickCheckTests -> QuickCheckTests -> Bool
Eq, Num QuickCheckTests
Ord QuickCheckTests
Num QuickCheckTests
-> Ord QuickCheckTests
-> (QuickCheckTests -> Rational)
-> Real QuickCheckTests
QuickCheckTests -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: QuickCheckTests -> Rational
$ctoRational :: QuickCheckTests -> Rational
$cp2Real :: Ord QuickCheckTests
$cp1Real :: Num QuickCheckTests
Real, Int -> QuickCheckTests
QuickCheckTests -> Int
QuickCheckTests -> [QuickCheckTests]
QuickCheckTests -> QuickCheckTests
QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
QuickCheckTests
-> QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
(QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests)
-> (Int -> QuickCheckTests)
-> (QuickCheckTests -> Int)
-> (QuickCheckTests -> [QuickCheckTests])
-> (QuickCheckTests -> QuickCheckTests -> [QuickCheckTests])
-> (QuickCheckTests -> QuickCheckTests -> [QuickCheckTests])
-> (QuickCheckTests
    -> QuickCheckTests -> QuickCheckTests -> [QuickCheckTests])
-> Enum QuickCheckTests
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: QuickCheckTests
-> QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
$cenumFromThenTo :: QuickCheckTests
-> QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
enumFromTo :: QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
$cenumFromTo :: QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
enumFromThen :: QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
$cenumFromThen :: QuickCheckTests -> QuickCheckTests -> [QuickCheckTests]
enumFrom :: QuickCheckTests -> [QuickCheckTests]
$cenumFrom :: QuickCheckTests -> [QuickCheckTests]
fromEnum :: QuickCheckTests -> Int
$cfromEnum :: QuickCheckTests -> Int
toEnum :: Int -> QuickCheckTests
$ctoEnum :: Int -> QuickCheckTests
pred :: QuickCheckTests -> QuickCheckTests
$cpred :: QuickCheckTests -> QuickCheckTests
succ :: QuickCheckTests -> QuickCheckTests
$csucc :: QuickCheckTests -> QuickCheckTests
Enum, Enum QuickCheckTests
Real QuickCheckTests
Real QuickCheckTests
-> Enum QuickCheckTests
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests -> QuickCheckTests -> QuickCheckTests)
-> (QuickCheckTests
    -> QuickCheckTests -> (QuickCheckTests, QuickCheckTests))
-> (QuickCheckTests
    -> QuickCheckTests -> (QuickCheckTests, QuickCheckTests))
-> (QuickCheckTests -> Integer)
-> Integral QuickCheckTests
QuickCheckTests -> Integer
QuickCheckTests
-> QuickCheckTests -> (QuickCheckTests, QuickCheckTests)
QuickCheckTests -> QuickCheckTests -> QuickCheckTests
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: QuickCheckTests -> Integer
$ctoInteger :: QuickCheckTests -> Integer
divMod :: QuickCheckTests
-> QuickCheckTests -> (QuickCheckTests, QuickCheckTests)
$cdivMod :: QuickCheckTests
-> QuickCheckTests -> (QuickCheckTests, QuickCheckTests)
quotRem :: QuickCheckTests
-> QuickCheckTests -> (QuickCheckTests, QuickCheckTests)
$cquotRem :: QuickCheckTests
-> QuickCheckTests -> (QuickCheckTests, QuickCheckTests)
mod :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cmod :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
div :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cdiv :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
rem :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$crem :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
quot :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cquot :: QuickCheckTests -> QuickCheckTests -> QuickCheckTests
$cp2Integral :: Enum QuickCheckTests
$cp1Integral :: Real QuickCheckTests
Integral, Int -> QuickCheckTests -> ShowS
[QuickCheckTests] -> ShowS
QuickCheckTests -> TestName
(Int -> QuickCheckTests -> ShowS)
-> (QuickCheckTests -> TestName)
-> ([QuickCheckTests] -> ShowS)
-> Show QuickCheckTests
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
showList :: [QuickCheckTests] -> ShowS
$cshowList :: [QuickCheckTests] -> ShowS
show :: QuickCheckTests -> TestName
$cshow :: QuickCheckTests -> TestName
showsPrec :: Int -> QuickCheckTests -> ShowS
$cshowsPrec :: Int -> QuickCheckTests -> ShowS
Show, Typeable)

newtype QuickCheckReplay = QuickCheckReplay (Maybe Int)
  deriving (Typeable)

-- | If a test case fails unexpectedly, show the replay token
newtype QuickCheckShowReplay = QuickCheckShowReplay Bool
  deriving (Typeable)

-- | Size of the biggest test cases
newtype QuickCheckMaxSize = QuickCheckMaxSize Int
  deriving (Integer -> QuickCheckMaxSize
QuickCheckMaxSize -> QuickCheckMaxSize
QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
(QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize)
-> (Integer -> QuickCheckMaxSize)
-> Num QuickCheckMaxSize
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> QuickCheckMaxSize
$cfromInteger :: Integer -> QuickCheckMaxSize
signum :: QuickCheckMaxSize -> QuickCheckMaxSize
$csignum :: QuickCheckMaxSize -> QuickCheckMaxSize
abs :: QuickCheckMaxSize -> QuickCheckMaxSize
$cabs :: QuickCheckMaxSize -> QuickCheckMaxSize
negate :: QuickCheckMaxSize -> QuickCheckMaxSize
$cnegate :: QuickCheckMaxSize -> QuickCheckMaxSize
* :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$c* :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
- :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$c- :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
+ :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$c+ :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
Num, Eq QuickCheckMaxSize
Eq QuickCheckMaxSize
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Ordering)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> Ord QuickCheckMaxSize
QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
QuickCheckMaxSize -> QuickCheckMaxSize -> Ordering
QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cmin :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
max :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cmax :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
>= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c>= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
> :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c> :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
<= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c<= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
< :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c< :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
compare :: QuickCheckMaxSize -> QuickCheckMaxSize -> Ordering
$ccompare :: QuickCheckMaxSize -> QuickCheckMaxSize -> Ordering
$cp1Ord :: Eq QuickCheckMaxSize
Ord, QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
(QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> Bool)
-> Eq QuickCheckMaxSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c/= :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
== :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
$c== :: QuickCheckMaxSize -> QuickCheckMaxSize -> Bool
Eq, Num QuickCheckMaxSize
Ord QuickCheckMaxSize
Num QuickCheckMaxSize
-> Ord QuickCheckMaxSize
-> (QuickCheckMaxSize -> Rational)
-> Real QuickCheckMaxSize
QuickCheckMaxSize -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: QuickCheckMaxSize -> Rational
$ctoRational :: QuickCheckMaxSize -> Rational
$cp2Real :: Ord QuickCheckMaxSize
$cp1Real :: Num QuickCheckMaxSize
Real, Int -> QuickCheckMaxSize
QuickCheckMaxSize -> Int
QuickCheckMaxSize -> [QuickCheckMaxSize]
QuickCheckMaxSize -> QuickCheckMaxSize
QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
QuickCheckMaxSize
-> QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
(QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize)
-> (Int -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> Int)
-> (QuickCheckMaxSize -> [QuickCheckMaxSize])
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize])
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize])
-> (QuickCheckMaxSize
    -> QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize])
-> Enum QuickCheckMaxSize
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: QuickCheckMaxSize
-> QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
$cenumFromThenTo :: QuickCheckMaxSize
-> QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
enumFromTo :: QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
$cenumFromTo :: QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
enumFromThen :: QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
$cenumFromThen :: QuickCheckMaxSize -> QuickCheckMaxSize -> [QuickCheckMaxSize]
enumFrom :: QuickCheckMaxSize -> [QuickCheckMaxSize]
$cenumFrom :: QuickCheckMaxSize -> [QuickCheckMaxSize]
fromEnum :: QuickCheckMaxSize -> Int
$cfromEnum :: QuickCheckMaxSize -> Int
toEnum :: Int -> QuickCheckMaxSize
$ctoEnum :: Int -> QuickCheckMaxSize
pred :: QuickCheckMaxSize -> QuickCheckMaxSize
$cpred :: QuickCheckMaxSize -> QuickCheckMaxSize
succ :: QuickCheckMaxSize -> QuickCheckMaxSize
$csucc :: QuickCheckMaxSize -> QuickCheckMaxSize
Enum, Enum QuickCheckMaxSize
Real QuickCheckMaxSize
Real QuickCheckMaxSize
-> Enum QuickCheckMaxSize
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize)
-> (QuickCheckMaxSize
    -> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize))
-> (QuickCheckMaxSize
    -> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize))
-> (QuickCheckMaxSize -> Integer)
-> Integral QuickCheckMaxSize
QuickCheckMaxSize -> Integer
QuickCheckMaxSize
-> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize)
QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: QuickCheckMaxSize -> Integer
$ctoInteger :: QuickCheckMaxSize -> Integer
divMod :: QuickCheckMaxSize
-> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize)
$cdivMod :: QuickCheckMaxSize
-> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize)
quotRem :: QuickCheckMaxSize
-> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize)
$cquotRem :: QuickCheckMaxSize
-> QuickCheckMaxSize -> (QuickCheckMaxSize, QuickCheckMaxSize)
mod :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cmod :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
div :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cdiv :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
rem :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$crem :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
quot :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cquot :: QuickCheckMaxSize -> QuickCheckMaxSize -> QuickCheckMaxSize
$cp2Integral :: Enum QuickCheckMaxSize
$cp1Integral :: Real QuickCheckMaxSize
Integral, Int -> QuickCheckMaxSize -> ShowS
[QuickCheckMaxSize] -> ShowS
QuickCheckMaxSize -> TestName
(Int -> QuickCheckMaxSize -> ShowS)
-> (QuickCheckMaxSize -> TestName)
-> ([QuickCheckMaxSize] -> ShowS)
-> Show QuickCheckMaxSize
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
showList :: [QuickCheckMaxSize] -> ShowS
$cshowList :: [QuickCheckMaxSize] -> ShowS
show :: QuickCheckMaxSize -> TestName
$cshow :: QuickCheckMaxSize -> TestName
showsPrec :: Int -> QuickCheckMaxSize -> ShowS
$cshowsPrec :: Int -> QuickCheckMaxSize -> ShowS
Show, Typeable)

-- | Maximum number of of discarded tests per successful test before giving up.
newtype QuickCheckMaxRatio = QuickCheckMaxRatio Int
  deriving (Integer -> QuickCheckMaxRatio
QuickCheckMaxRatio -> QuickCheckMaxRatio
QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
(QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (Integer -> QuickCheckMaxRatio)
-> Num QuickCheckMaxRatio
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> QuickCheckMaxRatio
$cfromInteger :: Integer -> QuickCheckMaxRatio
signum :: QuickCheckMaxRatio -> QuickCheckMaxRatio
$csignum :: QuickCheckMaxRatio -> QuickCheckMaxRatio
abs :: QuickCheckMaxRatio -> QuickCheckMaxRatio
$cabs :: QuickCheckMaxRatio -> QuickCheckMaxRatio
negate :: QuickCheckMaxRatio -> QuickCheckMaxRatio
$cnegate :: QuickCheckMaxRatio -> QuickCheckMaxRatio
* :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$c* :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
- :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$c- :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
+ :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$c+ :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
Num, Eq QuickCheckMaxRatio
Eq QuickCheckMaxRatio
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Ordering)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> Ord QuickCheckMaxRatio
QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
QuickCheckMaxRatio -> QuickCheckMaxRatio -> Ordering
QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cmin :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
max :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cmax :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
>= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c>= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
> :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c> :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
<= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c<= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
< :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c< :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
compare :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Ordering
$ccompare :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Ordering
$cp1Ord :: Eq QuickCheckMaxRatio
Ord, QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
(QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool)
-> Eq QuickCheckMaxRatio
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c/= :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
== :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
$c== :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> Bool
Eq, Num QuickCheckMaxRatio
Ord QuickCheckMaxRatio
Num QuickCheckMaxRatio
-> Ord QuickCheckMaxRatio
-> (QuickCheckMaxRatio -> Rational)
-> Real QuickCheckMaxRatio
QuickCheckMaxRatio -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: QuickCheckMaxRatio -> Rational
$ctoRational :: QuickCheckMaxRatio -> Rational
$cp2Real :: Ord QuickCheckMaxRatio
$cp1Real :: Num QuickCheckMaxRatio
Real, Int -> QuickCheckMaxRatio
QuickCheckMaxRatio -> Int
QuickCheckMaxRatio -> [QuickCheckMaxRatio]
QuickCheckMaxRatio -> QuickCheckMaxRatio
QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
QuickCheckMaxRatio
-> QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
(QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (Int -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> Int)
-> (QuickCheckMaxRatio -> [QuickCheckMaxRatio])
-> (QuickCheckMaxRatio
    -> QuickCheckMaxRatio -> [QuickCheckMaxRatio])
-> (QuickCheckMaxRatio
    -> QuickCheckMaxRatio -> [QuickCheckMaxRatio])
-> (QuickCheckMaxRatio
    -> QuickCheckMaxRatio
    -> QuickCheckMaxRatio
    -> [QuickCheckMaxRatio])
-> Enum QuickCheckMaxRatio
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
$cenumFromThenTo :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
enumFromTo :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
$cenumFromTo :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
enumFromThen :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
$cenumFromThen :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> [QuickCheckMaxRatio]
enumFrom :: QuickCheckMaxRatio -> [QuickCheckMaxRatio]
$cenumFrom :: QuickCheckMaxRatio -> [QuickCheckMaxRatio]
fromEnum :: QuickCheckMaxRatio -> Int
$cfromEnum :: QuickCheckMaxRatio -> Int
toEnum :: Int -> QuickCheckMaxRatio
$ctoEnum :: Int -> QuickCheckMaxRatio
pred :: QuickCheckMaxRatio -> QuickCheckMaxRatio
$cpred :: QuickCheckMaxRatio -> QuickCheckMaxRatio
succ :: QuickCheckMaxRatio -> QuickCheckMaxRatio
$csucc :: QuickCheckMaxRatio -> QuickCheckMaxRatio
Enum, Enum QuickCheckMaxRatio
Real QuickCheckMaxRatio
Real QuickCheckMaxRatio
-> Enum QuickCheckMaxRatio
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio)
-> (QuickCheckMaxRatio
    -> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio))
-> (QuickCheckMaxRatio
    -> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio))
-> (QuickCheckMaxRatio -> Integer)
-> Integral QuickCheckMaxRatio
QuickCheckMaxRatio -> Integer
QuickCheckMaxRatio
-> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio)
QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: QuickCheckMaxRatio -> Integer
$ctoInteger :: QuickCheckMaxRatio -> Integer
divMod :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio)
$cdivMod :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio)
quotRem :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio)
$cquotRem :: QuickCheckMaxRatio
-> QuickCheckMaxRatio -> (QuickCheckMaxRatio, QuickCheckMaxRatio)
mod :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cmod :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
div :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cdiv :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
rem :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$crem :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
quot :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cquot :: QuickCheckMaxRatio -> QuickCheckMaxRatio -> QuickCheckMaxRatio
$cp2Integral :: Enum QuickCheckMaxRatio
$cp1Integral :: Real QuickCheckMaxRatio
Integral, Int -> QuickCheckMaxRatio -> ShowS
[QuickCheckMaxRatio] -> ShowS
QuickCheckMaxRatio -> TestName
(Int -> QuickCheckMaxRatio -> ShowS)
-> (QuickCheckMaxRatio -> TestName)
-> ([QuickCheckMaxRatio] -> ShowS)
-> Show QuickCheckMaxRatio
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
showList :: [QuickCheckMaxRatio] -> ShowS
$cshowList :: [QuickCheckMaxRatio] -> ShowS
show :: QuickCheckMaxRatio -> TestName
$cshow :: QuickCheckMaxRatio -> TestName
showsPrec :: Int -> QuickCheckMaxRatio -> ShowS
$cshowsPrec :: Int -> QuickCheckMaxRatio -> ShowS
Show, Typeable)

-- | Show the test cases that QuickCheck generates
newtype QuickCheckVerbose = QuickCheckVerbose Bool
  deriving (Typeable)

-- | Number of shrinks allowed before QuickCheck will fail a test.
newtype QuickCheckMaxShrinks = QuickCheckMaxShrinks Int
  deriving (Integer -> QuickCheckMaxShrinks
QuickCheckMaxShrinks -> QuickCheckMaxShrinks
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
(QuickCheckMaxShrinks
 -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (Integer -> QuickCheckMaxShrinks)
-> Num QuickCheckMaxShrinks
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> QuickCheckMaxShrinks
$cfromInteger :: Integer -> QuickCheckMaxShrinks
signum :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$csignum :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
abs :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cabs :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
negate :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cnegate :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
* :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$c* :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
- :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$c- :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
+ :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$c+ :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
Num, Eq QuickCheckMaxShrinks
Eq QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Ordering)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> Ord QuickCheckMaxShrinks
QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Ordering
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cmin :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
max :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cmax :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
>= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c>= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
> :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c> :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
<= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c<= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
< :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c< :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
compare :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Ordering
$ccompare :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Ordering
$cp1Ord :: Eq QuickCheckMaxShrinks
Ord, QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
(QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool)
-> Eq QuickCheckMaxShrinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c/= :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
== :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
$c== :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks -> Bool
Eq, Num QuickCheckMaxShrinks
Ord QuickCheckMaxShrinks
Num QuickCheckMaxShrinks
-> Ord QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks -> Rational)
-> Real QuickCheckMaxShrinks
QuickCheckMaxShrinks -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: QuickCheckMaxShrinks -> Rational
$ctoRational :: QuickCheckMaxShrinks -> Rational
$cp2Real :: Ord QuickCheckMaxShrinks
$cp1Real :: Num QuickCheckMaxShrinks
Real, Int -> QuickCheckMaxShrinks
QuickCheckMaxShrinks -> Int
QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
QuickCheckMaxShrinks -> QuickCheckMaxShrinks
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> [QuickCheckMaxShrinks]
(QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (Int -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks -> Int)
-> (QuickCheckMaxShrinks -> [QuickCheckMaxShrinks])
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks])
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks])
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks
    -> [QuickCheckMaxShrinks])
-> Enum QuickCheckMaxShrinks
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> [QuickCheckMaxShrinks]
$cenumFromThenTo :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> [QuickCheckMaxShrinks]
enumFromTo :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
$cenumFromTo :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
enumFromThen :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
$cenumFromThen :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
enumFrom :: QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
$cenumFrom :: QuickCheckMaxShrinks -> [QuickCheckMaxShrinks]
fromEnum :: QuickCheckMaxShrinks -> Int
$cfromEnum :: QuickCheckMaxShrinks -> Int
toEnum :: Int -> QuickCheckMaxShrinks
$ctoEnum :: Int -> QuickCheckMaxShrinks
pred :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cpred :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
succ :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$csucc :: QuickCheckMaxShrinks -> QuickCheckMaxShrinks
Enum, Enum QuickCheckMaxShrinks
Real QuickCheckMaxShrinks
Real QuickCheckMaxShrinks
-> Enum QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks -> QuickCheckMaxShrinks)
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks
    -> (QuickCheckMaxShrinks, QuickCheckMaxShrinks))
-> (QuickCheckMaxShrinks
    -> QuickCheckMaxShrinks
    -> (QuickCheckMaxShrinks, QuickCheckMaxShrinks))
-> (QuickCheckMaxShrinks -> Integer)
-> Integral QuickCheckMaxShrinks
QuickCheckMaxShrinks -> Integer
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks, QuickCheckMaxShrinks)
QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: QuickCheckMaxShrinks -> Integer
$ctoInteger :: QuickCheckMaxShrinks -> Integer
divMod :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks, QuickCheckMaxShrinks)
$cdivMod :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks, QuickCheckMaxShrinks)
quotRem :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks, QuickCheckMaxShrinks)
$cquotRem :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks
-> (QuickCheckMaxShrinks, QuickCheckMaxShrinks)
mod :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cmod :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
div :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cdiv :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
rem :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$crem :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
quot :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cquot :: QuickCheckMaxShrinks
-> QuickCheckMaxShrinks -> QuickCheckMaxShrinks
$cp2Integral :: Enum QuickCheckMaxShrinks
$cp1Integral :: Real QuickCheckMaxShrinks
Integral, Int -> QuickCheckMaxShrinks -> ShowS
[QuickCheckMaxShrinks] -> ShowS
QuickCheckMaxShrinks -> TestName
(Int -> QuickCheckMaxShrinks -> ShowS)
-> (QuickCheckMaxShrinks -> TestName)
-> ([QuickCheckMaxShrinks] -> ShowS)
-> Show QuickCheckMaxShrinks
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
showList :: [QuickCheckMaxShrinks] -> ShowS
$cshowList :: [QuickCheckMaxShrinks] -> ShowS
show :: QuickCheckMaxShrinks -> TestName
$cshow :: QuickCheckMaxShrinks -> TestName
showsPrec :: Int -> QuickCheckMaxShrinks -> ShowS
$cshowsPrec :: Int -> QuickCheckMaxShrinks -> ShowS
Show, Typeable)

instance IsOption QuickCheckTests where
  defaultValue :: QuickCheckTests
defaultValue = QuickCheckTests
100
  parseValue :: TestName -> Maybe QuickCheckTests
parseValue =
    -- We allow numeric underscores for readability; see
    -- https://github.com/feuerbach/tasty/issues/263
    (Int -> QuickCheckTests) -> Maybe Int -> Maybe QuickCheckTests
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> QuickCheckTests
QuickCheckTests (Maybe Int -> Maybe QuickCheckTests)
-> (TestName -> Maybe Int) -> TestName -> Maybe QuickCheckTests
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Int
forall a. Read a => TestName -> Maybe a
safeRead (TestName -> Maybe Int) -> ShowS -> TestName -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShowS
forall a. (a -> Bool) -> [a] -> [a]
filter (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'_')
  optionName :: Tagged QuickCheckTests TestName
optionName = TestName -> Tagged QuickCheckTests TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-tests"
  optionHelp :: Tagged QuickCheckTests TestName
optionHelp = TestName -> Tagged QuickCheckTests TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Number of test cases for QuickCheck to generate. Underscores accepted: e.g. 10_000_000"
  optionCLParser :: Parser QuickCheckTests
optionCLParser = Mod OptionFields QuickCheckTests -> Parser QuickCheckTests
forall v. IsOption v => Mod OptionFields v -> Parser v
mkOptionCLParser (Mod OptionFields QuickCheckTests -> Parser QuickCheckTests)
-> Mod OptionFields QuickCheckTests -> Parser QuickCheckTests
forall a b. (a -> b) -> a -> b
$ TestName -> Mod OptionFields QuickCheckTests
forall (f :: * -> *) a. HasMetavar f => TestName -> Mod f a
metavar TestName
"NUMBER"

instance IsOption QuickCheckReplay where
  defaultValue :: QuickCheckReplay
defaultValue = Maybe Int -> QuickCheckReplay
QuickCheckReplay Maybe Int
forall a. Maybe a
Nothing
  -- Reads a replay int seed
  parseValue :: TestName -> Maybe QuickCheckReplay
parseValue TestName
v = Maybe Int -> QuickCheckReplay
QuickCheckReplay (Maybe Int -> QuickCheckReplay)
-> (Int -> Maybe Int) -> Int -> QuickCheckReplay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> QuickCheckReplay) -> Maybe Int -> Maybe QuickCheckReplay
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TestName -> Maybe Int
forall a. Read a => TestName -> Maybe a
safeRead TestName
v
  optionName :: Tagged QuickCheckReplay TestName
optionName = TestName -> Tagged QuickCheckReplay TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-replay"
  optionHelp :: Tagged QuickCheckReplay TestName
optionHelp = TestName -> Tagged QuickCheckReplay TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Random seed to use for replaying a previous test run (use same --quickcheck-max-size)"
  optionCLParser :: Parser QuickCheckReplay
optionCLParser = Mod OptionFields QuickCheckReplay -> Parser QuickCheckReplay
forall v. IsOption v => Mod OptionFields v -> Parser v
mkOptionCLParser (Mod OptionFields QuickCheckReplay -> Parser QuickCheckReplay)
-> Mod OptionFields QuickCheckReplay -> Parser QuickCheckReplay
forall a b. (a -> b) -> a -> b
$ TestName -> Mod OptionFields QuickCheckReplay
forall (f :: * -> *) a. HasMetavar f => TestName -> Mod f a
metavar TestName
"SEED"

instance IsOption QuickCheckShowReplay where
  defaultValue :: QuickCheckShowReplay
defaultValue = Bool -> QuickCheckShowReplay
QuickCheckShowReplay Bool
False
  parseValue :: TestName -> Maybe QuickCheckShowReplay
parseValue = (Bool -> QuickCheckShowReplay)
-> Maybe Bool -> Maybe QuickCheckShowReplay
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> QuickCheckShowReplay
QuickCheckShowReplay (Maybe Bool -> Maybe QuickCheckShowReplay)
-> (TestName -> Maybe Bool)
-> TestName
-> Maybe QuickCheckShowReplay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Bool
safeReadBool
  optionName :: Tagged QuickCheckShowReplay TestName
optionName = TestName -> Tagged QuickCheckShowReplay TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-show-replay"
  optionHelp :: Tagged QuickCheckShowReplay TestName
optionHelp = TestName -> Tagged QuickCheckShowReplay TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Show a replay token for replaying tests"
  optionCLParser :: Parser QuickCheckShowReplay
optionCLParser = Maybe Char -> QuickCheckShowReplay -> Parser QuickCheckShowReplay
forall v. IsOption v => Maybe Char -> v -> Parser v
flagCLParser Maybe Char
forall a. Maybe a
Nothing (Bool -> QuickCheckShowReplay
QuickCheckShowReplay Bool
True)

defaultMaxSize :: Int
defaultMaxSize :: Int
defaultMaxSize = Args -> Int
QC.maxSize Args
QC.stdArgs

instance IsOption QuickCheckMaxSize where
  defaultValue :: QuickCheckMaxSize
defaultValue = Int -> QuickCheckMaxSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
defaultMaxSize
  parseValue :: TestName -> Maybe QuickCheckMaxSize
parseValue = (Int -> QuickCheckMaxSize) -> Maybe Int -> Maybe QuickCheckMaxSize
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> QuickCheckMaxSize
QuickCheckMaxSize (Maybe Int -> Maybe QuickCheckMaxSize)
-> (TestName -> Maybe Int) -> TestName -> Maybe QuickCheckMaxSize
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Int
forall a. Read a => TestName -> Maybe a
safeRead
  optionName :: Tagged QuickCheckMaxSize TestName
optionName = TestName -> Tagged QuickCheckMaxSize TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-max-size"
  optionHelp :: Tagged QuickCheckMaxSize TestName
optionHelp = TestName -> Tagged QuickCheckMaxSize TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Size of the biggest test cases quickcheck generates"
  optionCLParser :: Parser QuickCheckMaxSize
optionCLParser = Mod OptionFields QuickCheckMaxSize -> Parser QuickCheckMaxSize
forall v. IsOption v => Mod OptionFields v -> Parser v
mkOptionCLParser (Mod OptionFields QuickCheckMaxSize -> Parser QuickCheckMaxSize)
-> Mod OptionFields QuickCheckMaxSize -> Parser QuickCheckMaxSize
forall a b. (a -> b) -> a -> b
$ TestName -> Mod OptionFields QuickCheckMaxSize
forall (f :: * -> *) a. HasMetavar f => TestName -> Mod f a
metavar TestName
"NUMBER"

instance IsOption QuickCheckMaxRatio where
  defaultValue :: QuickCheckMaxRatio
defaultValue = Int -> QuickCheckMaxRatio
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> QuickCheckMaxRatio) -> Int -> QuickCheckMaxRatio
forall a b. (a -> b) -> a -> b
$ Args -> Int
QC.maxDiscardRatio Args
QC.stdArgs
  parseValue :: TestName -> Maybe QuickCheckMaxRatio
parseValue = (Int -> QuickCheckMaxRatio)
-> Maybe Int -> Maybe QuickCheckMaxRatio
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> QuickCheckMaxRatio
QuickCheckMaxRatio (Maybe Int -> Maybe QuickCheckMaxRatio)
-> (TestName -> Maybe Int) -> TestName -> Maybe QuickCheckMaxRatio
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Int
forall a. Read a => TestName -> Maybe a
safeRead
  optionName :: Tagged QuickCheckMaxRatio TestName
optionName = TestName -> Tagged QuickCheckMaxRatio TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-max-ratio"
  optionHelp :: Tagged QuickCheckMaxRatio TestName
optionHelp = TestName -> Tagged QuickCheckMaxRatio TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Maximum number of discared tests per successful test before giving up"
  optionCLParser :: Parser QuickCheckMaxRatio
optionCLParser = Mod OptionFields QuickCheckMaxRatio -> Parser QuickCheckMaxRatio
forall v. IsOption v => Mod OptionFields v -> Parser v
mkOptionCLParser (Mod OptionFields QuickCheckMaxRatio -> Parser QuickCheckMaxRatio)
-> Mod OptionFields QuickCheckMaxRatio -> Parser QuickCheckMaxRatio
forall a b. (a -> b) -> a -> b
$ TestName -> Mod OptionFields QuickCheckMaxRatio
forall (f :: * -> *) a. HasMetavar f => TestName -> Mod f a
metavar TestName
"NUMBER"

instance IsOption QuickCheckVerbose where
  defaultValue :: QuickCheckVerbose
defaultValue = Bool -> QuickCheckVerbose
QuickCheckVerbose Bool
False
  parseValue :: TestName -> Maybe QuickCheckVerbose
parseValue = (Bool -> QuickCheckVerbose)
-> Maybe Bool -> Maybe QuickCheckVerbose
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> QuickCheckVerbose
QuickCheckVerbose (Maybe Bool -> Maybe QuickCheckVerbose)
-> (TestName -> Maybe Bool) -> TestName -> Maybe QuickCheckVerbose
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Bool
safeReadBool
  optionName :: Tagged QuickCheckVerbose TestName
optionName = TestName -> Tagged QuickCheckVerbose TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-verbose"
  optionHelp :: Tagged QuickCheckVerbose TestName
optionHelp = TestName -> Tagged QuickCheckVerbose TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Show the generated test cases"
  optionCLParser :: Parser QuickCheckVerbose
optionCLParser = Mod FlagFields QuickCheckVerbose
-> QuickCheckVerbose -> Parser QuickCheckVerbose
forall v. IsOption v => Mod FlagFields v -> v -> Parser v
mkFlagCLParser Mod FlagFields QuickCheckVerbose
forall a. Monoid a => a
mempty (Bool -> QuickCheckVerbose
QuickCheckVerbose Bool
True)

instance IsOption QuickCheckMaxShrinks where
  defaultValue :: QuickCheckMaxShrinks
defaultValue = Int -> QuickCheckMaxShrinks
QuickCheckMaxShrinks (Args -> Int
QC.maxShrinks Args
QC.stdArgs)
  parseValue :: TestName -> Maybe QuickCheckMaxShrinks
parseValue = (Int -> QuickCheckMaxShrinks)
-> Maybe Int -> Maybe QuickCheckMaxShrinks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> QuickCheckMaxShrinks
QuickCheckMaxShrinks (Maybe Int -> Maybe QuickCheckMaxShrinks)
-> (TestName -> Maybe Int)
-> TestName
-> Maybe QuickCheckMaxShrinks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestName -> Maybe Int
forall a. Read a => TestName -> Maybe a
safeRead
  optionName :: Tagged QuickCheckMaxShrinks TestName
optionName = TestName -> Tagged QuickCheckMaxShrinks TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"quickcheck-shrinks"
  optionHelp :: Tagged QuickCheckMaxShrinks TestName
optionHelp = TestName -> Tagged QuickCheckMaxShrinks TestName
forall (m :: * -> *) a. Monad m => a -> m a
return TestName
"Number of shrinks allowed before QuickCheck will fail a test"
  optionCLParser :: Parser QuickCheckMaxShrinks
optionCLParser = Mod OptionFields QuickCheckMaxShrinks
-> Parser QuickCheckMaxShrinks
forall v. IsOption v => Mod OptionFields v -> Parser v
mkOptionCLParser (Mod OptionFields QuickCheckMaxShrinks
 -> Parser QuickCheckMaxShrinks)
-> Mod OptionFields QuickCheckMaxShrinks
-> Parser QuickCheckMaxShrinks
forall a b. (a -> b) -> a -> b
$ TestName -> Mod OptionFields QuickCheckMaxShrinks
forall (f :: * -> *) a. HasMetavar f => TestName -> Mod f a
metavar TestName
"NUMBER"

-- | Convert tasty options into QuickCheck options.
--
-- This is a low-level function that was originally added for tasty-hspec
-- but may be used by others.
--
-- @since 0.9.1
optionSetToArgs :: OptionSet -> IO (Int, QC.Args)
optionSetToArgs :: OptionSet -> IO (Int, Args)
optionSetToArgs OptionSet
opts = do
  Int
replaySeed <- case Maybe Int
mReplay of
    Maybe Int
Nothing -> (StdGen -> (Int, StdGen)) -> IO Int
forall (m :: * -> *) a. MonadIO m => (StdGen -> (a, StdGen)) -> m a
getStdRandom ((Int, Int) -> StdGen -> (Int, StdGen)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (Int
1,Int
999999))
    Just Int
seed -> Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
seed

  let args :: Args
args = Args
QC.stdArgs
        { chatty :: Bool
QC.chatty          = Bool
False
        , maxSuccess :: Int
QC.maxSuccess      = Int
nTests
        , maxSize :: Int
QC.maxSize         = Int
maxSize
        , replay :: Maybe (QCGen, Int)
QC.replay          = (QCGen, Int) -> Maybe (QCGen, Int)
forall a. a -> Maybe a
Just (Int -> QCGen
mkQCGen Int
replaySeed, Int
0)
        , maxDiscardRatio :: Int
QC.maxDiscardRatio = Int
maxRatio
        , maxShrinks :: Int
QC.maxShrinks      = Int
maxShrinks
        }

  (Int, Args) -> IO (Int, Args)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
replaySeed, Args
args)

  where
    QuickCheckTests      Int
nTests     = OptionSet -> QuickCheckTests
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
    QuickCheckReplay     Maybe Int
mReplay    = OptionSet -> QuickCheckReplay
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
    QuickCheckMaxSize    Int
maxSize    = OptionSet -> QuickCheckMaxSize
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
    QuickCheckMaxRatio   Int
maxRatio   = OptionSet -> QuickCheckMaxRatio
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
    QuickCheckMaxShrinks Int
maxShrinks = OptionSet -> QuickCheckMaxShrinks
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts

instance IsTest QC where
  testOptions :: Tagged QC [OptionDescription]
testOptions = [OptionDescription] -> Tagged QC [OptionDescription]
forall (m :: * -> *) a. Monad m => a -> m a
return
    [ Proxy QuickCheckTests -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckTests
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckTests)
    , Proxy QuickCheckReplay -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckReplay
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckReplay)
    , Proxy QuickCheckShowReplay -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckShowReplay
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckShowReplay)
    , Proxy QuickCheckMaxSize -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckMaxSize
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckMaxSize)
    , Proxy QuickCheckMaxRatio -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckMaxRatio
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckMaxRatio)
    , Proxy QuickCheckVerbose -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckVerbose
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckVerbose)
    , Proxy QuickCheckMaxShrinks -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy QuickCheckMaxShrinks
forall k (t :: k). Proxy t
Proxy :: Proxy QuickCheckMaxShrinks)
    ]

  run :: OptionSet -> QC -> (Progress -> IO ()) -> IO Result
run OptionSet
opts (QC Property
prop) Progress -> IO ()
_yieldProgress = do
    (Int
replaySeed, Args
args) <- OptionSet -> IO (Int, Args)
optionSetToArgs OptionSet
opts

    let
      QuickCheckShowReplay Bool
showReplay = OptionSet -> QuickCheckShowReplay
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
      QuickCheckVerbose    Bool
verbose    = OptionSet -> QuickCheckVerbose
forall v. IsOption v => OptionSet -> v
lookupOption OptionSet
opts
      maxSize :: Int
maxSize = Args -> Int
QC.maxSize Args
args
      testRunner :: Args -> Property -> IO Result
testRunner = if Bool
verbose
                     then Args -> Property -> IO Result
forall prop. Testable prop => Args -> prop -> IO Result
QC.verboseCheckWithResult
                     else Args -> Property -> IO Result
forall prop. Testable prop => Args -> prop -> IO Result
QC.quickCheckWithResult
      replayMsg :: TestName
replayMsg = Int -> Int -> TestName
makeReplayMsg Int
replaySeed Int
maxSize

    -- Quickcheck already catches exceptions, no need to do it here.
    Result
r <- Args -> Property -> IO Result
testRunner Args
args Property
prop

    TestName
qcOutput <- TestName -> IO TestName
formatMessage (TestName -> IO TestName) -> TestName -> IO TestName
forall a b. (a -> b) -> a -> b
$ Result -> TestName
QC.output Result
r
    let qcOutputNl :: TestName
qcOutputNl =
          if TestName
"\n" TestName -> TestName -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` TestName
qcOutput
            then TestName
qcOutput
            else TestName
qcOutput TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ TestName
"\n"
        testSuccessful :: Bool
testSuccessful = Result -> Bool
successful Result
r
        putReplayInDesc :: Bool
putReplayInDesc = (Bool -> Bool
not Bool
testSuccessful) Bool -> Bool -> Bool
|| Bool
showReplay
    Result -> IO Result
forall (m :: * -> *) a. Monad m => a -> m a
return (Result -> IO Result) -> Result -> IO Result
forall a b. (a -> b) -> a -> b
$
      (if Bool
testSuccessful then TestName -> Result
testPassed else TestName -> Result
testFailed)
      (TestName
qcOutputNl TestName -> ShowS
forall a. [a] -> [a] -> [a]
++
        (if Bool
putReplayInDesc then TestName
replayMsg else TestName
""))

successful :: QC.Result -> Bool
successful :: Result -> Bool
successful Result
r =
  case Result
r of
    QC.Success {} -> Bool
True
    Result
_ -> Bool
False

makeReplayMsg :: Int -> Int -> String
makeReplayMsg :: Int -> Int -> TestName
makeReplayMsg Int
seed Int
size = let
    sizeStr :: TestName
sizeStr = if (Int
size Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
defaultMaxSize)
                 then TestName -> Int -> TestName
forall r. PrintfType r => TestName -> r
printf TestName
" --quickcheck-max-size=%d" Int
size
                 else TestName
""
  in TestName -> Int -> ShowS
forall r. PrintfType r => TestName -> r
printf TestName
"Use --quickcheck-replay=%d%s to reproduce." Int
seed TestName
sizeStr