hedgehog-1.5: Release with confidence.

Safe Haskell | None
Language | Haskell2010

Hedgehog.Internal.Property

Contents

- Property
- Group
- TestT
- Coverage
- Confidence
- Internal

Synopsis

- data Property = Property {
  - propertyConfig :: !PropertyConfig
  - propertyTest :: PropertyT IO ()
  }
- newtype PropertyT (m :: Type -> Type) a = PropertyT {
  - unPropertyT :: TestT (GenT m) a
  }
- newtype PropertyName = PropertyName {
  - unPropertyName :: String
  }
- data PropertyConfig = PropertyConfig {
  - propertyDiscardLimit :: !DiscardLimit
  - propertyShrinkLimit :: !ShrinkLimit
  - propertyShrinkRetries :: !ShrinkRetries
  - propertyTerminationCriteria :: !TerminationCriteria
  - propertySkip :: Maybe Skip
  }
- newtype TestLimit = TestLimit Int
- newtype TestCount = TestCount Int
- newtype DiscardLimit = DiscardLimit Int
- newtype DiscardCount = DiscardCount Int
- newtype ShrinkLimit = ShrinkLimit Int
- newtype ShrinkCount = ShrinkCount Int
- data Skip
  - = SkipNothing
  - | SkipToTest TestCount DiscardCount
  - | SkipToShrink TestCount DiscardCount ShrinkPath
- newtype ShrinkPath = ShrinkPath [Int]
- newtype ShrinkRetries = ShrinkRetries Int
- withTests :: TestLimit -> Property -> Property
- withDiscards :: DiscardLimit -> Property -> Property
- withShrinks :: ShrinkLimit -> Property -> Property
- withRetries :: ShrinkRetries -> Property -> Property
- withSkip :: Skip -> Property -> Property
- property :: HasCallStack => PropertyT IO () -> Property
- test :: forall (m :: Type -> Type) a. Monad m => TestT m a -> PropertyT m a
- forAll :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a
- forAllT :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => GenT m a -> PropertyT m a
- forAllWith :: forall (m :: Type -> Type) a. (Monad m, HasCallStack) => (a -> String) -> Gen a -> PropertyT m a
- forAllWithT :: forall (m :: Type -> Type) a. (Monad m, HasCallStack) => (a -> String) -> GenT m a -> PropertyT m a
- defaultMinTests :: TestLimit
- discard :: forall (m :: Type -> Type) a. Monad m => PropertyT m a
- skipCompress :: Skip -> String
- shrinkPathCompress :: ShrinkPath -> String
- skipDecompress :: String -> Maybe Skip
- shrinkPathDecompress :: String -> Maybe ShrinkPath
- data Group = Group {
  - groupName :: !GroupName
  - groupProperties :: ![(PropertyName, Property)]
  }
- newtype GroupName = GroupName {
  - unGroupName :: String
  }
- newtype PropertyCount = PropertyCount Int
- class Monad m => MonadTest (m :: Type -> Type) where
  - liftTest :: Test a -> m a
- type Test = TestT Identity
- newtype TestT (m :: Type -> Type) a = TestT {
  - unTest :: ExceptT Failure (WriterT Journal m) a
  }
- data Log
  - = Annotation (Maybe Span) String
  - | Footnote String
  - | Label (Label Cover)
- newtype Journal = Journal {
  - journalLogs :: [Log]
  }
- data Failure = Failure (Maybe Span) String (Maybe Diff)
- data Diff = Diff {
  - diffPrefix :: String
  - diffRemoved :: String
  - diffInfix :: String
  - diffAdded :: String
  - diffSuffix :: String
  - diffValue :: ValueDiff
  }
- annotate :: (MonadTest m, HasCallStack) => String -> m ()
- annotateShow :: (MonadTest m, Show a, HasCallStack) => a -> m ()
- footnote :: MonadTest m => String -> m ()
- footnoteShow :: (MonadTest m, Show a) => a -> m ()
- failure :: (MonadTest m, HasCallStack) => m a
- success :: MonadTest m => m ()
- assert :: (MonadTest m, HasCallStack) => Bool -> m ()
- diff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> (a -> b -> Bool) -> b -> m ()
- (===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- (/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- eval :: (MonadTest m, HasCallStack) => a -> m a
- evalNF :: (MonadTest m, NFData a, HasCallStack) => a -> m a
- evalM :: (MonadTest m, MonadCatch m, HasCallStack) => m a -> m a
- evalIO :: (MonadTest m, MonadIO m, HasCallStack) => IO a -> m a
- evalEither :: (MonadTest m, Show x, HasCallStack) => Either x a -> m a
- evalEitherM :: (MonadTest m, Show x, MonadCatch m, HasCallStack) => m (Either x a) -> m a
- evalExceptT :: (MonadTest m, Show x, HasCallStack) => ExceptT x m a -> m a
- evalMaybe :: (MonadTest m, HasCallStack) => Maybe a -> m a
- evalMaybeM :: (MonadTest m, MonadCatch m, HasCallStack) => m (Maybe a) -> m a
- newtype Coverage a = Coverage {
  - coverageLabels :: Map LabelName (Label a)
  }
- data Label a = MkLabel {
  - labelName :: !LabelName
  - labelLocation :: !(Maybe Span)
  - labelMinimum :: !CoverPercentage
  - labelAnnotation :: !a
  }
- newtype LabelName = LabelName {
  - unLabelName :: String
  }
- cover :: (MonadTest m, HasCallStack) => CoverPercentage -> LabelName -> Bool -> m ()
- classify :: (MonadTest m, HasCallStack) => LabelName -> Bool -> m ()
- label :: (MonadTest m, HasCallStack) => LabelName -> m ()
- collect :: (MonadTest m, Show a, HasCallStack) => a -> m ()
- coverPercentage :: TestCount -> CoverCount -> CoverPercentage
- labelCovered :: TestCount -> Label CoverCount -> Bool
- coverageSuccess :: TestCount -> Coverage CoverCount -> Bool
- coverageFailures :: TestCount -> Coverage CoverCount -> [Label CoverCount]
- journalCoverage :: Journal -> Coverage CoverCount
- data Cover
  - = NoCover
  - | Cover
- newtype CoverCount = CoverCount {
  - unCoverCount :: Int
  }
- newtype CoverPercentage = CoverPercentage {
  - unCoverPercentage :: Double
  }
- toCoverCount :: Cover -> CoverCount
- newtype Confidence = Confidence {
  - unConfidence :: Int64
  }
- data TerminationCriteria
  - = EarlyTermination Confidence TestLimit
  - | NoEarlyTermination Confidence TestLimit
  - | NoConfidenceTermination TestLimit
- confidenceSuccess :: TestCount -> Confidence -> Coverage CoverCount -> Bool
- confidenceFailure :: TestCount -> Confidence -> Coverage CoverCount -> Bool
- withConfidence :: Confidence -> Property -> Property
- verifiedTermination :: Property -> Property
- defaultConfidence :: Confidence
- defaultConfig :: PropertyConfig
- mapConfig :: (PropertyConfig -> PropertyConfig) -> Property -> Property
- failDiff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> b -> m ()
- failException :: (MonadTest m, HasCallStack) => SomeException -> m a
- failWith :: (MonadTest m, HasCallStack) => Maybe Diff -> String -> m a
- writeLog :: MonadTest m => Log -> m ()
- mkTest :: (Either Failure a, Journal) -> Test a
- mkTestT :: m (Either Failure a, Journal) -> TestT m a
- runTest :: Test a -> (Either Failure a, Journal)
- runTestT :: TestT m a -> m (Either Failure a, Journal)
- wilsonBounds :: Integer -> Integer -> Double -> (Double, Double)

# Property

data Property Source #

A property test, along with some configurable limits like how many times to run the test.

Constructors

Property |

Fields

- propertyConfig :: !PropertyConfig
- propertyTest :: PropertyT IO ()

newtype PropertyT (m :: Type -> Type) a Source #

The property monad transformer allows both the generation of test inputs and the assertion of expectations.

Constructors

PropertyT |

Fields

- unPropertyT :: TestT (GenT m) a

#### Instances

Instances details

MonadTransDistributive PropertyT Source # |

Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type Transformer t PropertyT m |
Instance details Defined in Hedgehog.Internal.Property type Transformer t PropertyT m = (Transformer t GenT m, Transformer t TestT (GenT m))

Methods

distributeT :: forall f (m :: Type -> Type) a. Transformer f PropertyT m => PropertyT (f m) a -> f (PropertyT m) a Source #

MonadTrans PropertyT Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Monad m => m a -> PropertyT m a Source #
MFunctor PropertyT Source # |
Instance details Defined in Hedgehog.Internal.Property Methods hoist :: Monad m => (forall a. m a -> n a) -> PropertyT m b -> PropertyT n b Source #
MonadBaseControl b m => MonadBaseControl b (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftBaseWith :: (RunInBase (PropertyT m) b -> b a) -> PropertyT m a Source # restoreM :: StM (PropertyT m) a -> PropertyT m a Source #
MonadError e m => MonadError e (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods throwError :: e -> PropertyT m a Source # catchError :: PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a Source #
MonadReader r m => MonadReader r (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods ask :: PropertyT m r Source # local :: (r -> r) -> PropertyT m a -> PropertyT m a Source # reader :: (r -> a) -> PropertyT m a Source #
MonadState s m => MonadState s (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods get :: PropertyT m s Source # put :: s -> PropertyT m () Source # state :: (s -> (a, s)) -> PropertyT m a Source #
MonadBase b m => MonadBase b (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftBase :: b α -> PropertyT m α Source #
MonadIO m => MonadIO (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftIO :: IO a -> PropertyT m a Source #
MonadCatch m => MonadCatch (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods catch :: (HasCallStack, Exception e) => PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a Source #
MonadThrow m => MonadThrow (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods throwM :: (HasCallStack, Exception e) => e -> PropertyT m a Source #
MonadPlus m => Alternative (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods empty :: PropertyT m a Source # (<|>) :: PropertyT m a -> PropertyT m a -> PropertyT m a Source # some :: PropertyT m a -> PropertyT m [a] Source # many :: PropertyT m a -> PropertyT m [a] Source #
Monad m => Applicative (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods pure :: a -> PropertyT m a Source # (<*>) :: PropertyT m (a -> b) -> PropertyT m a -> PropertyT m b Source # liftA2 :: (a -> b -> c) -> PropertyT m a -> PropertyT m b -> PropertyT m c Source # (*>) :: PropertyT m a -> PropertyT m b -> PropertyT m b Source # (<*) :: PropertyT m a -> PropertyT m b -> PropertyT m a Source #
Functor m => Functor (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fmap :: (a -> b) -> PropertyT m a -> PropertyT m b Source # (<$) :: a -> PropertyT m b -> PropertyT m a Source #
Monad m => Monad (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (>>=) :: PropertyT m a -> (a -> PropertyT m b) -> PropertyT m b Source # (>>) :: PropertyT m a -> PropertyT m b -> PropertyT m b Source # return :: a -> PropertyT m a Source #
MonadPlus m => MonadPlus (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mzero :: PropertyT m a Source # mplus :: PropertyT m a -> PropertyT m a -> PropertyT m a Source #
Monad m => MonadFail (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fail :: String -> PropertyT m a Source #
Monad m => MonadTest (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> PropertyT m a Source #
PrimMonad m => PrimMonad (PropertyT m) Source # |

Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (PropertyT m) |
Instance details Defined in Hedgehog.Internal.Property type PrimState (PropertyT m) = PrimState m

Methods

primitive :: (State# (PrimState (PropertyT m)) -> (# State# (PrimState (PropertyT m)), a #)) -> PropertyT m a Source #

MonadResource m => MonadResource (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftResourceT :: ResourceT IO a -> PropertyT m a Source #
type Transformer t PropertyT m Source # |
Instance details Defined in Hedgehog.Internal.Property type Transformer t PropertyT m = (Transformer t GenT m, Transformer t TestT (GenT m))
type PrimState (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property type PrimState (PropertyT m) = PrimState m
type StM (PropertyT m) a Source # |
Instance details Defined in Hedgehog.Internal.Property type StM (PropertyT m) a = StM (TestT (GenT m)) a

newtype PropertyName Source #

The name of a property.

Should be constructed using `OverloadedStrings`:

      "apples" :: PropertyName

Constructors

PropertyName |

Fields

- unPropertyName :: String

#### Instances

Instances details

Semigroup PropertyName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: PropertyName -> PropertyName -> PropertyName Source # sconcat :: NonEmpty PropertyName -> PropertyName Source # stimes :: Integral b => b -> PropertyName -> PropertyName Source #
IsString PropertyName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fromString :: String -> PropertyName Source #
Show PropertyName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> PropertyName -> ShowS Source # show :: PropertyName -> String Source # showList :: [PropertyName] -> ShowS Source #
Eq PropertyName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: PropertyName -> PropertyName -> Bool Source # (/=) :: PropertyName -> PropertyName -> Bool Source #
Ord PropertyName Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: PropertyName -> PropertyName -> Ordering Source #

(<) :: PropertyName -> PropertyName -> Bool Source #

(<=) :: PropertyName -> PropertyName -> Bool Source #

(>) :: PropertyName -> PropertyName -> Bool Source #

(>=) :: PropertyName -> PropertyName -> Bool Source #

max :: PropertyName -> PropertyName -> PropertyName Source #

min :: PropertyName -> PropertyName -> PropertyName Source #

Lift PropertyName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => PropertyName -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => PropertyName -> Code m PropertyName Source #

data PropertyConfig Source #

Configuration for a property test.

Constructors

PropertyConfig |

Fields

- propertyDiscardLimit :: !DiscardLimit
- propertyShrinkLimit :: !ShrinkLimit
- propertyShrinkRetries :: !ShrinkRetries
- propertyTerminationCriteria :: !TerminationCriteria
- propertySkip :: Maybe Skip

  If this is `Nothing`, we take the Skip from the environment variable `HEDGEHOG_SKIP`.

#### Instances

Instances details

Show PropertyConfig Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> PropertyConfig -> ShowS Source # show :: PropertyConfig -> String Source # showList :: [PropertyConfig] -> ShowS Source #
Eq PropertyConfig Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: PropertyConfig -> PropertyConfig -> Bool Source # (/=) :: PropertyConfig -> PropertyConfig -> Bool Source #
Ord PropertyConfig Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: PropertyConfig -> PropertyConfig -> Ordering Source #

(<) :: PropertyConfig -> PropertyConfig -> Bool Source #

(<=) :: PropertyConfig -> PropertyConfig -> Bool Source #

(>) :: PropertyConfig -> PropertyConfig -> Bool Source #

(>=) :: PropertyConfig -> PropertyConfig -> Bool Source #

max :: PropertyConfig -> PropertyConfig -> PropertyConfig Source #

min :: PropertyConfig -> PropertyConfig -> PropertyConfig Source #

Lift PropertyConfig Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => PropertyConfig -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => PropertyConfig -> Code m PropertyConfig Source #

newtype TestLimit Source #

The number of successful tests that need to be run before a property test is considered successful.

Can be constructed using numeric literals:

      200 :: TestLimit

Constructors

TestLimit Int |

#### Instances

Instances details

Enum TestLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: TestLimit -> TestLimit Source #

pred :: TestLimit -> TestLimit Source #

toEnum :: Int -> TestLimit Source #

fromEnum :: TestLimit -> Int Source #

enumFrom :: TestLimit -> [TestLimit] Source #

enumFromThen :: TestLimit -> TestLimit -> [TestLimit] Source #

enumFromTo :: TestLimit -> TestLimit -> [TestLimit] Source #

enumFromThenTo :: TestLimit -> TestLimit -> TestLimit -> [TestLimit] Source #

Num TestLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (+) :: TestLimit -> TestLimit -> TestLimit Source # (-) :: TestLimit -> TestLimit -> TestLimit Source # (*) :: TestLimit -> TestLimit -> TestLimit Source # negate :: TestLimit -> TestLimit Source # abs :: TestLimit -> TestLimit Source # signum :: TestLimit -> TestLimit Source # fromInteger :: Integer -> TestLimit Source #
Integral TestLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: TestLimit -> TestLimit -> TestLimit Source #

rem :: TestLimit -> TestLimit -> TestLimit Source #

div :: TestLimit -> TestLimit -> TestLimit Source #

mod :: TestLimit -> TestLimit -> TestLimit Source #

quotRem :: TestLimit -> TestLimit -> (TestLimit, TestLimit) Source #

divMod :: TestLimit -> TestLimit -> (TestLimit, TestLimit) Source #

toInteger :: TestLimit -> Integer Source #

Real TestLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: TestLimit -> Rational Source #
Show TestLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> TestLimit -> ShowS Source # show :: TestLimit -> String Source # showList :: [TestLimit] -> ShowS Source #
Eq TestLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: TestLimit -> TestLimit -> Bool Source # (/=) :: TestLimit -> TestLimit -> Bool Source #
Ord TestLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: TestLimit -> TestLimit -> Ordering Source #

(<) :: TestLimit -> TestLimit -> Bool Source #

(<=) :: TestLimit -> TestLimit -> Bool Source #

(>) :: TestLimit -> TestLimit -> Bool Source #

(>=) :: TestLimit -> TestLimit -> Bool Source #

max :: TestLimit -> TestLimit -> TestLimit Source #

min :: TestLimit -> TestLimit -> TestLimit Source #

Lift TestLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => TestLimit -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => TestLimit -> Code m TestLimit Source #

newtype TestCount Source #

The number of tests a property ran successfully.

Constructors

TestCount Int |

#### Instances

Instances details

Enum TestCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: TestCount -> TestCount Source #

pred :: TestCount -> TestCount Source #

toEnum :: Int -> TestCount Source #

fromEnum :: TestCount -> Int Source #

enumFrom :: TestCount -> [TestCount] Source #

enumFromThen :: TestCount -> TestCount -> [TestCount] Source #

enumFromTo :: TestCount -> TestCount -> [TestCount] Source #

enumFromThenTo :: TestCount -> TestCount -> TestCount -> [TestCount] Source #

Num TestCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (+) :: TestCount -> TestCount -> TestCount Source # (-) :: TestCount -> TestCount -> TestCount Source # (*) :: TestCount -> TestCount -> TestCount Source # negate :: TestCount -> TestCount Source # abs :: TestCount -> TestCount Source # signum :: TestCount -> TestCount Source # fromInteger :: Integer -> TestCount Source #
Integral TestCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: TestCount -> TestCount -> TestCount Source #

rem :: TestCount -> TestCount -> TestCount Source #

div :: TestCount -> TestCount -> TestCount Source #

mod :: TestCount -> TestCount -> TestCount Source #

quotRem :: TestCount -> TestCount -> (TestCount, TestCount) Source #

divMod :: TestCount -> TestCount -> (TestCount, TestCount) Source #

toInteger :: TestCount -> Integer Source #

Real TestCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: TestCount -> Rational Source #
Show TestCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> TestCount -> ShowS Source # show :: TestCount -> String Source # showList :: [TestCount] -> ShowS Source #
Eq TestCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: TestCount -> TestCount -> Bool Source # (/=) :: TestCount -> TestCount -> Bool Source #
Ord TestCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: TestCount -> TestCount -> Ordering Source #

(<) :: TestCount -> TestCount -> Bool Source #

(<=) :: TestCount -> TestCount -> Bool Source #

(>) :: TestCount -> TestCount -> Bool Source #

(>=) :: TestCount -> TestCount -> Bool Source #

max :: TestCount -> TestCount -> TestCount Source #

min :: TestCount -> TestCount -> TestCount Source #

Lift TestCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => TestCount -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => TestCount -> Code m TestCount Source #

newtype DiscardLimit Source #

The number of discards to allow before giving up.

Can be constructed using numeric literals:

      10000 :: DiscardLimit

Constructors

DiscardLimit Int |

#### Instances

Instances details

Enum DiscardLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: DiscardLimit -> DiscardLimit Source #

pred :: DiscardLimit -> DiscardLimit Source #

toEnum :: Int -> DiscardLimit Source #

fromEnum :: DiscardLimit -> Int Source #

enumFrom :: DiscardLimit -> [DiscardLimit] Source #

enumFromThen :: DiscardLimit -> DiscardLimit -> [DiscardLimit] Source #

enumFromTo :: DiscardLimit -> DiscardLimit -> [DiscardLimit] Source #

enumFromThenTo :: DiscardLimit -> DiscardLimit -> DiscardLimit -> [DiscardLimit] Source #

Num DiscardLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

(-) :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

(*) :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

negate :: DiscardLimit -> DiscardLimit Source #

abs :: DiscardLimit -> DiscardLimit Source #

signum :: DiscardLimit -> DiscardLimit Source #

fromInteger :: Integer -> DiscardLimit Source #

Integral DiscardLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

rem :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

div :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

mod :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

quotRem :: DiscardLimit -> DiscardLimit -> (DiscardLimit, DiscardLimit) Source #

divMod :: DiscardLimit -> DiscardLimit -> (DiscardLimit, DiscardLimit) Source #

toInteger :: DiscardLimit -> Integer Source #

Real DiscardLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: DiscardLimit -> Rational Source #
Show DiscardLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> DiscardLimit -> ShowS Source # show :: DiscardLimit -> String Source # showList :: [DiscardLimit] -> ShowS Source #
Eq DiscardLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: DiscardLimit -> DiscardLimit -> Bool Source # (/=) :: DiscardLimit -> DiscardLimit -> Bool Source #
Ord DiscardLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: DiscardLimit -> DiscardLimit -> Ordering Source #

(<) :: DiscardLimit -> DiscardLimit -> Bool Source #

(<=) :: DiscardLimit -> DiscardLimit -> Bool Source #

(>) :: DiscardLimit -> DiscardLimit -> Bool Source #

(>=) :: DiscardLimit -> DiscardLimit -> Bool Source #

max :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

min :: DiscardLimit -> DiscardLimit -> DiscardLimit Source #

Lift DiscardLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => DiscardLimit -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => DiscardLimit -> Code m DiscardLimit Source #

newtype DiscardCount Source #

The number of tests a property had to discard.

Constructors

DiscardCount Int |

#### Instances

Instances details

Enum DiscardCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: DiscardCount -> DiscardCount Source #

pred :: DiscardCount -> DiscardCount Source #

toEnum :: Int -> DiscardCount Source #

fromEnum :: DiscardCount -> Int Source #

enumFrom :: DiscardCount -> [DiscardCount] Source #

enumFromThen :: DiscardCount -> DiscardCount -> [DiscardCount] Source #

enumFromTo :: DiscardCount -> DiscardCount -> [DiscardCount] Source #

enumFromThenTo :: DiscardCount -> DiscardCount -> DiscardCount -> [DiscardCount] Source #

Num DiscardCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: DiscardCount -> DiscardCount -> DiscardCount Source #

(-) :: DiscardCount -> DiscardCount -> DiscardCount Source #

(*) :: DiscardCount -> DiscardCount -> DiscardCount Source #

negate :: DiscardCount -> DiscardCount Source #

abs :: DiscardCount -> DiscardCount Source #

signum :: DiscardCount -> DiscardCount Source #

fromInteger :: Integer -> DiscardCount Source #

Integral DiscardCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: DiscardCount -> DiscardCount -> DiscardCount Source #

rem :: DiscardCount -> DiscardCount -> DiscardCount Source #

div :: DiscardCount -> DiscardCount -> DiscardCount Source #

mod :: DiscardCount -> DiscardCount -> DiscardCount Source #

quotRem :: DiscardCount -> DiscardCount -> (DiscardCount, DiscardCount) Source #

divMod :: DiscardCount -> DiscardCount -> (DiscardCount, DiscardCount) Source #

toInteger :: DiscardCount -> Integer Source #

Real DiscardCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: DiscardCount -> Rational Source #
Show DiscardCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> DiscardCount -> ShowS Source # show :: DiscardCount -> String Source # showList :: [DiscardCount] -> ShowS Source #
Eq DiscardCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: DiscardCount -> DiscardCount -> Bool Source # (/=) :: DiscardCount -> DiscardCount -> Bool Source #
Ord DiscardCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: DiscardCount -> DiscardCount -> Ordering Source #

(<) :: DiscardCount -> DiscardCount -> Bool Source #

(<=) :: DiscardCount -> DiscardCount -> Bool Source #

(>) :: DiscardCount -> DiscardCount -> Bool Source #

(>=) :: DiscardCount -> DiscardCount -> Bool Source #

max :: DiscardCount -> DiscardCount -> DiscardCount Source #

min :: DiscardCount -> DiscardCount -> DiscardCount Source #

Lift DiscardCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => DiscardCount -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => DiscardCount -> Code m DiscardCount Source #

newtype ShrinkLimit Source #

The number of shrinks to try before giving up on shrinking.

Can be constructed using numeric literals:

      1000 :: ShrinkLimit

Constructors

ShrinkLimit Int |

#### Instances

Instances details

Enum ShrinkLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: ShrinkLimit -> ShrinkLimit Source #

pred :: ShrinkLimit -> ShrinkLimit Source #

toEnum :: Int -> ShrinkLimit Source #

fromEnum :: ShrinkLimit -> Int Source #

enumFrom :: ShrinkLimit -> [ShrinkLimit] Source #

enumFromThen :: ShrinkLimit -> ShrinkLimit -> [ShrinkLimit] Source #

enumFromTo :: ShrinkLimit -> ShrinkLimit -> [ShrinkLimit] Source #

enumFromThenTo :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit -> [ShrinkLimit] Source #

Num ShrinkLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

(-) :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

(*) :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

negate :: ShrinkLimit -> ShrinkLimit Source #

abs :: ShrinkLimit -> ShrinkLimit Source #

signum :: ShrinkLimit -> ShrinkLimit Source #

fromInteger :: Integer -> ShrinkLimit Source #

Integral ShrinkLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

rem :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

div :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

mod :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

quotRem :: ShrinkLimit -> ShrinkLimit -> (ShrinkLimit, ShrinkLimit) Source #

divMod :: ShrinkLimit -> ShrinkLimit -> (ShrinkLimit, ShrinkLimit) Source #

toInteger :: ShrinkLimit -> Integer Source #

Real ShrinkLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: ShrinkLimit -> Rational Source #
Show ShrinkLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> ShrinkLimit -> ShowS Source # show :: ShrinkLimit -> String Source # showList :: [ShrinkLimit] -> ShowS Source #
Eq ShrinkLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: ShrinkLimit -> ShrinkLimit -> Bool Source # (/=) :: ShrinkLimit -> ShrinkLimit -> Bool Source #
Ord ShrinkLimit Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: ShrinkLimit -> ShrinkLimit -> Ordering Source #

(<) :: ShrinkLimit -> ShrinkLimit -> Bool Source #

(<=) :: ShrinkLimit -> ShrinkLimit -> Bool Source #

(>) :: ShrinkLimit -> ShrinkLimit -> Bool Source #

(>=) :: ShrinkLimit -> ShrinkLimit -> Bool Source #

max :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

min :: ShrinkLimit -> ShrinkLimit -> ShrinkLimit Source #

Lift ShrinkLimit Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => ShrinkLimit -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ShrinkLimit -> Code m ShrinkLimit Source #

newtype ShrinkCount Source #

The numbers of times a property was able to shrink after a failing test.

Constructors

ShrinkCount Int |

#### Instances

Instances details

Enum ShrinkCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: ShrinkCount -> ShrinkCount Source #

pred :: ShrinkCount -> ShrinkCount Source #

toEnum :: Int -> ShrinkCount Source #

fromEnum :: ShrinkCount -> Int Source #

enumFrom :: ShrinkCount -> [ShrinkCount] Source #

enumFromThen :: ShrinkCount -> ShrinkCount -> [ShrinkCount] Source #

enumFromTo :: ShrinkCount -> ShrinkCount -> [ShrinkCount] Source #

enumFromThenTo :: ShrinkCount -> ShrinkCount -> ShrinkCount -> [ShrinkCount] Source #

Num ShrinkCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

(-) :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

(*) :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

negate :: ShrinkCount -> ShrinkCount Source #

abs :: ShrinkCount -> ShrinkCount Source #

signum :: ShrinkCount -> ShrinkCount Source #

fromInteger :: Integer -> ShrinkCount Source #

Integral ShrinkCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

rem :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

div :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

mod :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

quotRem :: ShrinkCount -> ShrinkCount -> (ShrinkCount, ShrinkCount) Source #

divMod :: ShrinkCount -> ShrinkCount -> (ShrinkCount, ShrinkCount) Source #

toInteger :: ShrinkCount -> Integer Source #

Real ShrinkCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: ShrinkCount -> Rational Source #
Show ShrinkCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> ShrinkCount -> ShowS Source # show :: ShrinkCount -> String Source # showList :: [ShrinkCount] -> ShowS Source #
Eq ShrinkCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: ShrinkCount -> ShrinkCount -> Bool Source # (/=) :: ShrinkCount -> ShrinkCount -> Bool Source #
Ord ShrinkCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: ShrinkCount -> ShrinkCount -> Ordering Source #

(<) :: ShrinkCount -> ShrinkCount -> Bool Source #

(<=) :: ShrinkCount -> ShrinkCount -> Bool Source #

(>) :: ShrinkCount -> ShrinkCount -> Bool Source #

(>=) :: ShrinkCount -> ShrinkCount -> Bool Source #

max :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

min :: ShrinkCount -> ShrinkCount -> ShrinkCount Source #

data Skip Source #

Where to start running a property's tests.

Constructors

SkipNothing | Don't skip anything.
SkipToTest TestCount DiscardCount | Skip to a specific test number. If it fails, shrink as normal. If it passes, move on to the next test. Coverage checks are disabled. We also need to count discards, since failing "after 7 tests" points at a different generated value than failing "after 7 tests and 5 discards".
SkipToShrink TestCount DiscardCount ShrinkPath | Skip to a specific test number and shrink state. If it fails, stop without shrinking further. If it passes, the property will pass without running any more tests. Due to implementation details, all intermediate shrink states - those on the direct path from the original test input to the target state - will be tested too, and their results discarded.

#### Instances

Instances details

IsString Skip Source #

We use this instance to support usage like

      withSkip "3:aB"

It throws an error if the input is not a valid compressed `Skip`.

Instance details Defined in Hedgehog.Internal.Property Methods fromString :: String -> Skip Source #
Show Skip Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Skip -> ShowS Source # show :: Skip -> String Source # showList :: [Skip] -> ShowS Source #
Eq Skip Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Skip -> Skip -> Bool Source # (/=) :: Skip -> Skip -> Bool Source #
Ord Skip Source # |
Instance details Defined in Hedgehog.Internal.Property Methods compare :: Skip -> Skip -> Ordering Source # (<) :: Skip -> Skip -> Bool Source # (<=) :: Skip -> Skip -> Bool Source # (>) :: Skip -> Skip -> Bool Source # (>=) :: Skip -> Skip -> Bool Source # max :: Skip -> Skip -> Skip Source # min :: Skip -> Skip -> Skip Source #
Lift Skip Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => Skip -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Skip -> Code m Skip Source #

newtype ShrinkPath Source #

The path taken to reach a shrink state.

Constructors

ShrinkPath [Int] |

#### Instances

Instances details

Show ShrinkPath Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> ShrinkPath -> ShowS Source # show :: ShrinkPath -> String Source # showList :: [ShrinkPath] -> ShowS Source #
Eq ShrinkPath Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: ShrinkPath -> ShrinkPath -> Bool Source # (/=) :: ShrinkPath -> ShrinkPath -> Bool Source #
Ord ShrinkPath Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: ShrinkPath -> ShrinkPath -> Ordering Source #

(<) :: ShrinkPath -> ShrinkPath -> Bool Source #

(<=) :: ShrinkPath -> ShrinkPath -> Bool Source #

(>) :: ShrinkPath -> ShrinkPath -> Bool Source #

(>=) :: ShrinkPath -> ShrinkPath -> Bool Source #

max :: ShrinkPath -> ShrinkPath -> ShrinkPath Source #

min :: ShrinkPath -> ShrinkPath -> ShrinkPath Source #

Lift ShrinkPath Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => ShrinkPath -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ShrinkPath -> Code m ShrinkPath Source #

newtype ShrinkRetries Source #

The number of times to re-run a test during shrinking. This is useful if you are testing something which fails non-deterministically and you want to increase the change of getting a good shrink.

If you are doing parallel state machine testing, you should probably set shrink retries to something like `10`. This will mean that during shrinking, a parallel test case requires 10 successful runs before it is passes and we try a different shrink.

Can be constructed using numeric literals:

      0 :: ShrinkRetries

Constructors

ShrinkRetries Int |

#### Instances

Instances details

Enum ShrinkRetries Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: ShrinkRetries -> ShrinkRetries Source #

pred :: ShrinkRetries -> ShrinkRetries Source #

toEnum :: Int -> ShrinkRetries Source #

fromEnum :: ShrinkRetries -> Int Source #

enumFrom :: ShrinkRetries -> [ShrinkRetries] Source #

enumFromThen :: ShrinkRetries -> ShrinkRetries -> [ShrinkRetries] Source #

enumFromTo :: ShrinkRetries -> ShrinkRetries -> [ShrinkRetries] Source #

enumFromThenTo :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries -> [ShrinkRetries] Source #

Num ShrinkRetries Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

(-) :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

(*) :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

negate :: ShrinkRetries -> ShrinkRetries Source #

abs :: ShrinkRetries -> ShrinkRetries Source #

signum :: ShrinkRetries -> ShrinkRetries Source #

fromInteger :: Integer -> ShrinkRetries Source #

Integral ShrinkRetries Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

rem :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

div :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

mod :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

quotRem :: ShrinkRetries -> ShrinkRetries -> (ShrinkRetries, ShrinkRetries) Source #

divMod :: ShrinkRetries -> ShrinkRetries -> (ShrinkRetries, ShrinkRetries) Source #

toInteger :: ShrinkRetries -> Integer Source #

Real ShrinkRetries Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: ShrinkRetries -> Rational Source #
Show ShrinkRetries Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> ShrinkRetries -> ShowS Source # show :: ShrinkRetries -> String Source # showList :: [ShrinkRetries] -> ShowS Source #
Eq ShrinkRetries Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: ShrinkRetries -> ShrinkRetries -> Bool Source # (/=) :: ShrinkRetries -> ShrinkRetries -> Bool Source #
Ord ShrinkRetries Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: ShrinkRetries -> ShrinkRetries -> Ordering Source #

(<) :: ShrinkRetries -> ShrinkRetries -> Bool Source #

(<=) :: ShrinkRetries -> ShrinkRetries -> Bool Source #

(>) :: ShrinkRetries -> ShrinkRetries -> Bool Source #

(>=) :: ShrinkRetries -> ShrinkRetries -> Bool Source #

max :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

min :: ShrinkRetries -> ShrinkRetries -> ShrinkRetries Source #

Lift ShrinkRetries Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => ShrinkRetries -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ShrinkRetries -> Code m ShrinkRetries Source #

withTests :: TestLimit -> Property -> Property Source #

Set the number of times a property should be executed before it is considered successful.

If you have a test that does not involve any generators and thus does not need to run repeatedly, you can use `withTests 1` to define a property that will only be checked once.

withDiscards :: DiscardLimit -> Property -> Property Source #

Set the number of times a property is allowed to discard before the test runner gives up.

withShrinks :: ShrinkLimit -> Property -> Property Source #

Set the number of times a property is allowed to shrink before the test runner gives up and prints the counterexample.

withRetries :: ShrinkRetries -> Property -> Property Source #

Set the number of times a property will be executed for each shrink before the test runner gives up and tries a different shrink. See `ShrinkRetries` for more information.

withSkip :: Skip -> Property -> Property Source #

Set the target that a property will skip to before it starts to run.

property :: HasCallStack => PropertyT IO () -> Property Source #

Creates a property with the default configuration.

test :: forall (m :: Type -> Type) a. Monad m => TestT m a -> PropertyT m a Source #

Lift a test in to a property.

Because both `TestT` and `PropertyT` have `MonadTest` instances, this function is not often required. It can however be useful for writing functions directly in `TestT` and thus gaining a `MonadTransControl` instance at the expense of not being able to generate additional inputs using `forAll`.

An example where this is useful is parallel state machine testing, as `executeParallel` requires `MonadBaseControl` `IO` in order to be able to spawn threads in `MonadTest`.

forAll :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

forAllT :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => GenT m a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

forAllWith :: forall (m :: Type -> Type) a. (Monad m, HasCallStack) => (a -> String) -> Gen a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

This is a the same as `forAll` but allows the user to provide a custom rendering function. This is useful for values which don't have a `Show` instance.

forAllWithT :: forall (m :: Type -> Type) a. (Monad m, HasCallStack) => (a -> String) -> GenT m a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

This is a the same as `forAllT` but allows the user to provide a custom rendering function. This is useful for values which don't have a `Show` instance.

defaultMinTests :: TestLimit Source #

The minimum amount of tests to run for a `Property`

discard :: forall (m :: Type -> Type) a. Monad m => PropertyT m a Source #

Discards the current test entirely.

skipCompress :: Skip -> String Source #

Compress a Skip into a hopefully-short alphanumeric string.

The bit that might be long is the `ShrinkPath` in `SkipToShrink`. For that, we encode the path components in base 26, alternating between uppercase and lowercase alphabets to distinguish list elements. Additionally when we have runs of equal components, we use the normal base 10 encoding to indicate the length.

This gives something which is hopefully quite short, but a human can roughly interpret it by eyeball.

shrinkPathCompress :: ShrinkPath -> String Source #

Compress a `ShrinkPath` into a hopefully-short alphanumeric string.

We encode the path components in base 26, alternating between uppercase and lowercase alphabets to distinguish list elements. Additionally when we have runs of equal components, we use the normal base 10 encoding to indicate the length.

skipDecompress :: String -> Maybe Skip Source #

Decompress a `Skip`.

This satisfies

      skipDecompress (skipCompress a) == Just a

shrinkPathDecompress :: String -> Maybe ShrinkPath Source #

Decompress a `ShrinkPath`.

This satisfies

      shrinkPathDecompress (shrinkPathCompress a) == Just a

# Group

data Group Source #

A named collection of property tests.

Constructors

Group |

Fields

- groupName :: !GroupName
- groupProperties :: ![(PropertyName, Property)]

newtype GroupName Source #

The name of a group of properties.

Should be constructed using `OverloadedStrings`:

      "fruit" :: GroupName

Constructors

GroupName |

Fields

- unGroupName :: String

#### Instances

Instances details

Semigroup GroupName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: GroupName -> GroupName -> GroupName Source # sconcat :: NonEmpty GroupName -> GroupName Source # stimes :: Integral b => b -> GroupName -> GroupName Source #
IsString GroupName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fromString :: String -> GroupName Source #
Show GroupName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> GroupName -> ShowS Source # show :: GroupName -> String Source # showList :: [GroupName] -> ShowS Source #
Eq GroupName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: GroupName -> GroupName -> Bool Source # (/=) :: GroupName -> GroupName -> Bool Source #
Ord GroupName Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: GroupName -> GroupName -> Ordering Source #

(<) :: GroupName -> GroupName -> Bool Source #

(<=) :: GroupName -> GroupName -> Bool Source #

(>) :: GroupName -> GroupName -> Bool Source #

(>=) :: GroupName -> GroupName -> Bool Source #

max :: GroupName -> GroupName -> GroupName Source #

min :: GroupName -> GroupName -> GroupName Source #

Lift GroupName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => GroupName -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => GroupName -> Code m GroupName Source #

newtype PropertyCount Source #

The number of properties in a group.

Constructors

PropertyCount Int |

#### Instances

Instances details

Enum PropertyCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

succ :: PropertyCount -> PropertyCount Source #

pred :: PropertyCount -> PropertyCount Source #

toEnum :: Int -> PropertyCount Source #

fromEnum :: PropertyCount -> Int Source #

enumFrom :: PropertyCount -> [PropertyCount] Source #

enumFromThen :: PropertyCount -> PropertyCount -> [PropertyCount] Source #

enumFromTo :: PropertyCount -> PropertyCount -> [PropertyCount] Source #

enumFromThenTo :: PropertyCount -> PropertyCount -> PropertyCount -> [PropertyCount] Source #

Num PropertyCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: PropertyCount -> PropertyCount -> PropertyCount Source #

(-) :: PropertyCount -> PropertyCount -> PropertyCount Source #

(*) :: PropertyCount -> PropertyCount -> PropertyCount Source #

negate :: PropertyCount -> PropertyCount Source #

abs :: PropertyCount -> PropertyCount Source #

signum :: PropertyCount -> PropertyCount Source #

fromInteger :: Integer -> PropertyCount Source #

Integral PropertyCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

quot :: PropertyCount -> PropertyCount -> PropertyCount Source #

rem :: PropertyCount -> PropertyCount -> PropertyCount Source #

div :: PropertyCount -> PropertyCount -> PropertyCount Source #

mod :: PropertyCount -> PropertyCount -> PropertyCount Source #

quotRem :: PropertyCount -> PropertyCount -> (PropertyCount, PropertyCount) Source #

divMod :: PropertyCount -> PropertyCount -> (PropertyCount, PropertyCount) Source #

toInteger :: PropertyCount -> Integer Source #

Real PropertyCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods toRational :: PropertyCount -> Rational Source #
Show PropertyCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> PropertyCount -> ShowS Source # show :: PropertyCount -> String Source # showList :: [PropertyCount] -> ShowS Source #
Eq PropertyCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: PropertyCount -> PropertyCount -> Bool Source # (/=) :: PropertyCount -> PropertyCount -> Bool Source #
Ord PropertyCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: PropertyCount -> PropertyCount -> Ordering Source #

(<) :: PropertyCount -> PropertyCount -> Bool Source #

(<=) :: PropertyCount -> PropertyCount -> Bool Source #

(>) :: PropertyCount -> PropertyCount -> Bool Source #

(>=) :: PropertyCount -> PropertyCount -> Bool Source #

max :: PropertyCount -> PropertyCount -> PropertyCount Source #

min :: PropertyCount -> PropertyCount -> PropertyCount Source #

# TestT

class Monad m => MonadTest (m :: Type -> Type) where Source #

Methods

liftTest :: Test a -> m a Source #

#### Instances

Instances details

Monad m => MonadTest (PropertyT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> PropertyT m a Source #
Monad m => MonadTest (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> TestT m a Source #
MonadTest m => MonadTest (ResourceT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> ResourceT m a Source #
MonadTest m => MonadTest (MaybeT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> MaybeT m a Source #
MonadTest m => MonadTest (ExceptT x m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> ExceptT x m a Source #
MonadTest m => MonadTest (IdentityT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> IdentityT m a Source #
MonadTest m => MonadTest (ReaderT r m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> ReaderT r m a Source #
MonadTest m => MonadTest (StateT s m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> StateT s m a Source #
MonadTest m => MonadTest (StateT s m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> StateT s m a Source #
(MonadTest m, Monoid w) => MonadTest (WriterT w m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> WriterT w m a Source #
(MonadTest m, Monoid w) => MonadTest (WriterT w m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> WriterT w m a Source #
MonadTest m => MonadTest (ContT r m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> ContT r m a Source #
(MonadTest m, Monoid w) => MonadTest (RWST r w s m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> RWST r w s m a Source #
(MonadTest m, Monoid w) => MonadTest (RWST r w s m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> RWST r w s m a Source #

type Test = TestT Identity Source #

A test monad allows the assertion of expectations.

newtype TestT (m :: Type -> Type) a Source #

A test monad transformer allows the assertion of expectations.

Constructors

TestT |

Fields

- unTest :: ExceptT Failure (WriterT Journal m) a

#### Instances

Instances details

MonadTransDistributive TestT Source # |

Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type Transformer t TestT m |
Instance details Defined in Hedgehog.Internal.Property type Transformer t TestT m = (Transformer t (WriterT Journal) m, Transformer t (ExceptT Failure) (WriterT Journal m))

Methods

distributeT :: forall f (m :: Type -> Type) a. Transformer f TestT m => TestT (f m) a -> f (TestT m) a Source #

MonadTransControl TestT Source # |

Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type StT TestT a |
Instance details Defined in Hedgehog.Internal.Property type StT TestT a = (Either Failure a, Journal)

Methods

liftWith :: Monad m => (Run TestT -> m a) -> TestT m a Source #

restoreT :: Monad m => m (StT TestT a) -> TestT m a Source #

MonadTrans TestT Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Monad m => m a -> TestT m a Source #
MFunctor TestT Source # |
Instance details Defined in Hedgehog.Internal.Property Methods hoist :: Monad m => (forall a. m a -> n a) -> TestT m b -> TestT n b Source #
MonadBaseControl b m => MonadBaseControl b (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftBaseWith :: (RunInBase (TestT m) b -> b a) -> TestT m a Source # restoreM :: StM (TestT m) a -> TestT m a Source #
MonadError e m => MonadError e (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods throwError :: e -> TestT m a Source # catchError :: TestT m a -> (e -> TestT m a) -> TestT m a Source #
MonadReader r m => MonadReader r (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods ask :: TestT m r Source # local :: (r -> r) -> TestT m a -> TestT m a Source # reader :: (r -> a) -> TestT m a Source #
MonadState s m => MonadState s (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods get :: TestT m s Source # put :: s -> TestT m () Source # state :: (s -> (a, s)) -> TestT m a Source #
MonadBase b m => MonadBase b (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftBase :: b α -> TestT m α Source #
MonadIO m => MonadIO (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftIO :: IO a -> TestT m a Source #
MonadCatch m => MonadCatch (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods catch :: (HasCallStack, Exception e) => TestT m a -> (e -> TestT m a) -> TestT m a Source #
MonadThrow m => MonadThrow (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods throwM :: (HasCallStack, Exception e) => e -> TestT m a Source #
Monad m => Applicative (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods pure :: a -> TestT m a Source # (<*>) :: TestT m (a -> b) -> TestT m a -> TestT m b Source # liftA2 :: (a -> b -> c) -> TestT m a -> TestT m b -> TestT m c Source # (*>) :: TestT m a -> TestT m b -> TestT m b Source # (<*) :: TestT m a -> TestT m b -> TestT m a Source #
Functor m => Functor (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fmap :: (a -> b) -> TestT m a -> TestT m b Source # (<$) :: a -> TestT m b -> TestT m a Source #
Monad m => Monad (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (>>=) :: TestT m a -> (a -> TestT m b) -> TestT m b Source # (>>) :: TestT m a -> TestT m b -> TestT m b Source # return :: a -> TestT m a Source #
Monad m => MonadFail (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fail :: String -> TestT m a Source #
Monad m => MonadTest (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftTest :: Test a -> TestT m a Source #
PrimMonad m => PrimMonad (TestT m) Source # |

Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (TestT m) |
Instance details Defined in Hedgehog.Internal.Property type PrimState (TestT m) = PrimState m

Methods

primitive :: (State# (PrimState (TestT m)) -> (# State# (PrimState (TestT m)), a #)) -> TestT m a Source #

MonadResource m => MonadResource (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods liftResourceT :: ResourceT IO a -> TestT m a Source #
type StT TestT a Source # |
Instance details Defined in Hedgehog.Internal.Property type StT TestT a = (Either Failure a, Journal)
type Transformer t TestT m Source # |
Instance details Defined in Hedgehog.Internal.Property type Transformer t TestT m = (Transformer t (WriterT Journal) m, Transformer t (ExceptT Failure) (WriterT Journal m))
type PrimState (TestT m) Source # |
Instance details Defined in Hedgehog.Internal.Property type PrimState (TestT m) = PrimState m
type StM (TestT m) a Source # |
Instance details Defined in Hedgehog.Internal.Property type StM (TestT m) a = ComposeSt TestT m a

data Log Source #

Log messages which are recorded during a test run.

Constructors

Annotation (Maybe Span) String |
Footnote String |
Label (Label Cover) |

#### Instances

Instances details

Show Log Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Log -> ShowS Source # show :: Log -> String Source # showList :: [Log] -> ShowS Source #
Eq Log Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Log -> Log -> Bool Source # (/=) :: Log -> Log -> Bool Source #

newtype Journal Source #

A record containing the details of a test run.

Constructors

Journal |

Fields

- journalLogs :: [Log]

#### Instances

Instances details

Monoid Journal Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mempty :: Journal Source # mappend :: Journal -> Journal -> Journal Source # mconcat :: [Journal] -> Journal Source #
Semigroup Journal Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: Journal -> Journal -> Journal Source # sconcat :: NonEmpty Journal -> Journal Source # stimes :: Integral b => b -> Journal -> Journal Source #
Show Journal Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Journal -> ShowS Source # show :: Journal -> String Source # showList :: [Journal] -> ShowS Source #
Eq Journal Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Journal -> Journal -> Bool Source # (/=) :: Journal -> Journal -> Bool Source #

data Failure Source #

Details on where and why a test failed.

Constructors

Failure (Maybe Span) String (Maybe Diff) |

#### Instances

Instances details

Show Failure Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Failure -> ShowS Source # show :: Failure -> String Source # showList :: [Failure] -> ShowS Source #
Eq Failure Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Failure -> Failure -> Bool Source # (/=) :: Failure -> Failure -> Bool Source #

data Diff Source #

The difference between some expected and actual value.

Constructors

Diff |

Fields

- diffPrefix :: String
- diffRemoved :: String
- diffInfix :: String
- diffAdded :: String
- diffSuffix :: String
- diffValue :: ValueDiff

#### Instances

Instances details

Show Diff Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Diff -> ShowS Source # show :: Diff -> String Source # showList :: [Diff] -> ShowS Source #
Eq Diff Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Diff -> Diff -> Bool Source # (/=) :: Diff -> Diff -> Bool Source #

annotate :: (MonadTest m, HasCallStack) => String -> m () Source #

Annotates the source code with a message that might be useful for debugging a test failure.

annotateShow :: (MonadTest m, Show a, HasCallStack) => a -> m () Source #

Annotates the source code with a value that might be useful for debugging a test failure.

footnote :: MonadTest m => String -> m () Source #

Logs a message to be displayed as additional information in the footer of the failure report.

footnoteShow :: (MonadTest m, Show a) => a -> m () Source #

Logs a value to be displayed as additional information in the footer of the failure report.

failure :: (MonadTest m, HasCallStack) => m a Source #

Causes a test to fail.

success :: MonadTest m => m () Source #

Another name for `pure ()`.

assert :: (MonadTest m, HasCallStack) => Bool -> m () Source #

Fails the test if the condition provided is `False`.

diff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> (a -> b -> Bool) -> b -> m () Source #

Fails the test and shows a git-like diff if the comparison operation evaluates to `False` when applied to its arguments.

The comparison function is the second argument, which may be counter-intuitive to Haskell programmers. However, it allows operators to be written infix for easy reading:

      diff y (<) 87
      diff x (<=) r

This function behaves like the unix `diff` tool, which gives a 0 exit code if the compared files are identical, or a 1 exit code code otherwise. Like unix `diff`, if the arguments fail the comparison, a /diff is shown.

(===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 Source #

Fails the test if the two arguments provided are not equal.

(/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 Source #

Fails the test if the two arguments provided are equal.

eval :: (MonadTest m, HasCallStack) => a -> m a Source #

Fails the test if the value throws an exception when evaluated to weak head normal form (WHNF).

evalNF :: (MonadTest m, NFData a, HasCallStack) => a -> m a Source #

Fails the test if the value throws an exception when evaluated to normal form (NF).

evalM :: (MonadTest m, MonadCatch m, HasCallStack) => m a -> m a Source #

Fails the test if the action throws an exception.

The benefit of using this over simply letting the exception bubble up is that the location of the closest `evalM` will be shown in the output.

evalIO :: (MonadTest m, MonadIO m, HasCallStack) => IO a -> m a Source #

Fails the test if the `IO` action throws an exception.

The benefit of using this over `liftIO` is that the location of the exception will be shown in the output.

evalEither :: (MonadTest m, Show x, HasCallStack) => Either x a -> m a Source #

Fails the test if the `Either` is `Left`, otherwise returns the value in the `Right`.

evalEitherM :: (MonadTest m, Show x, MonadCatch m, HasCallStack) => m (Either x a) -> m a Source #

Fails the test if the action throws an exception, or if the `Either` is `Left`, otherwise returns the value in the `Right`.

evalExceptT :: (MonadTest m, Show x, HasCallStack) => ExceptT x m a -> m a Source #

Fails the test if the `ExceptT` is `Left`, otherwise returns the value in the `Right`.

evalMaybe :: (MonadTest m, HasCallStack) => Maybe a -> m a Source #

Fails the test if the `Maybe` is `Nothing`, otherwise returns the value in the `Just`.

evalMaybeM :: (MonadTest m, MonadCatch m, HasCallStack) => m (Maybe a) -> m a Source #

Fails the test if the action throws an exception, or if the `Maybe` is `Nothing`, otherwise returns the value in the `Just`.

# Coverage

newtype Coverage a Source #

The extent to which all classifiers cover a test.

When a given classification's coverage does not exceed the required minimum, the test will be failed.

Constructors

Coverage |

Fields

- coverageLabels :: Map LabelName (Label a)

#### Instances

Instances details

Functor Coverage Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fmap :: (a -> b) -> Coverage a -> Coverage b Source # (<$) :: a -> Coverage b -> Coverage a Source #
Foldable Coverage Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

fold :: Monoid m => Coverage m -> m Source #

foldMap :: Monoid m => (a -> m) -> Coverage a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Coverage a -> m Source #

foldr :: (a -> b -> b) -> b -> Coverage a -> b Source #

foldr' :: (a -> b -> b) -> b -> Coverage a -> b Source #

foldl :: (b -> a -> b) -> b -> Coverage a -> b Source #

foldl' :: (b -> a -> b) -> b -> Coverage a -> b Source #

foldr1 :: (a -> a -> a) -> Coverage a -> a Source #

foldl1 :: (a -> a -> a) -> Coverage a -> a Source #

toList :: Coverage a -> [a] Source #

null :: Coverage a -> Bool Source #

length :: Coverage a -> Int Source #

elem :: Eq a => a -> Coverage a -> Bool Source #

maximum :: Ord a => Coverage a -> a Source #

minimum :: Ord a => Coverage a -> a Source #

sum :: Num a => Coverage a -> a Source #

product :: Num a => Coverage a -> a Source #

Traversable Coverage Source # |
Instance details Defined in Hedgehog.Internal.Property Methods traverse :: Applicative f => (a -> f b) -> Coverage a -> f (Coverage b) Source # sequenceA :: Applicative f => Coverage (f a) -> f (Coverage a) Source # mapM :: Monad m => (a -> m b) -> Coverage a -> m (Coverage b) Source # sequence :: Monad m => Coverage (m a) -> m (Coverage a) Source #
(Semigroup a, Monoid a) => Monoid (Coverage a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mempty :: Coverage a Source # mappend :: Coverage a -> Coverage a -> Coverage a Source # mconcat :: [Coverage a] -> Coverage a Source #
Semigroup a => Semigroup (Coverage a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: Coverage a -> Coverage a -> Coverage a Source # sconcat :: NonEmpty (Coverage a) -> Coverage a Source # stimes :: Integral b => b -> Coverage a -> Coverage a Source #
Show a => Show (Coverage a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Coverage a -> ShowS Source # show :: Coverage a -> String Source # showList :: [Coverage a] -> ShowS Source #
Eq a => Eq (Coverage a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Coverage a -> Coverage a -> Bool Source # (/=) :: Coverage a -> Coverage a -> Bool Source #

data Label a Source #

The extent to which a test is covered by a classifier.

When a classifier's coverage does not exceed the required minimum, the test will be failed.

Constructors

MkLabel |

Fields

- labelName :: !LabelName
- labelLocation :: !(Maybe Span)
- labelMinimum :: !CoverPercentage
- labelAnnotation :: !a

#### Instances

Instances details

Functor Label Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fmap :: (a -> b) -> Label a -> Label b Source # (<$) :: a -> Label b -> Label a Source #
Foldable Label Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

fold :: Monoid m => Label m -> m Source #

foldMap :: Monoid m => (a -> m) -> Label a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Label a -> m Source #

foldr :: (a -> b -> b) -> b -> Label a -> b Source #

foldr' :: (a -> b -> b) -> b -> Label a -> b Source #

foldl :: (b -> a -> b) -> b -> Label a -> b Source #

foldl' :: (b -> a -> b) -> b -> Label a -> b Source #

foldr1 :: (a -> a -> a) -> Label a -> a Source #

foldl1 :: (a -> a -> a) -> Label a -> a Source #

toList :: Label a -> [a] Source #

null :: Label a -> Bool Source #

length :: Label a -> Int Source #

elem :: Eq a => a -> Label a -> Bool Source #

maximum :: Ord a => Label a -> a Source #

minimum :: Ord a => Label a -> a Source #

sum :: Num a => Label a -> a Source #

product :: Num a => Label a -> a Source #

Traversable Label Source # |
Instance details Defined in Hedgehog.Internal.Property Methods traverse :: Applicative f => (a -> f b) -> Label a -> f (Label b) Source # sequenceA :: Applicative f => Label (f a) -> f (Label a) Source # mapM :: Monad m => (a -> m b) -> Label a -> m (Label b) Source # sequence :: Monad m => Label (m a) -> m (Label a) Source #
Semigroup a => Semigroup (Label a) Source # | This semigroup is right biased. The name, location and percentage from the rightmost `Label` will be kept. This shouldn't be a problem since the library doesn't allow setting multiple classes with the same `ClassifierName`.
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: Label a -> Label a -> Label a Source # sconcat :: NonEmpty (Label a) -> Label a Source # stimes :: Integral b => b -> Label a -> Label a Source #
Show a => Show (Label a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Label a -> ShowS Source # show :: Label a -> String Source # showList :: [Label a] -> ShowS Source #
Eq a => Eq (Label a) Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Label a -> Label a -> Bool Source # (/=) :: Label a -> Label a -> Bool Source #

newtype LabelName Source #

The name of a classifier.

Should be constructed using `OverloadedStrings`:

      "apples" :: LabelName

Constructors

LabelName |

Fields

- unLabelName :: String

#### Instances

Instances details

Monoid LabelName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mempty :: LabelName Source # mappend :: LabelName -> LabelName -> LabelName Source # mconcat :: [LabelName] -> LabelName Source #
Semigroup LabelName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: LabelName -> LabelName -> LabelName Source # sconcat :: NonEmpty LabelName -> LabelName Source # stimes :: Integral b => b -> LabelName -> LabelName Source #
IsString LabelName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods fromString :: String -> LabelName Source #
Show LabelName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> LabelName -> ShowS Source # show :: LabelName -> String Source # showList :: [LabelName] -> ShowS Source #
Eq LabelName Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: LabelName -> LabelName -> Bool Source # (/=) :: LabelName -> LabelName -> Bool Source #
Ord LabelName Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: LabelName -> LabelName -> Ordering Source #

(<) :: LabelName -> LabelName -> Bool Source #

(<=) :: LabelName -> LabelName -> Bool Source #

(>) :: LabelName -> LabelName -> Bool Source #

(>=) :: LabelName -> LabelName -> Bool Source #

max :: LabelName -> LabelName -> LabelName Source #

min :: LabelName -> LabelName -> LabelName Source #

cover :: (MonadTest m, HasCallStack) => CoverPercentage -> LabelName -> Bool -> m () Source #

Require a certain percentage of the tests to be covered by the classifier.

       prop_with_coverage :: Property
       prop_with_coverage =
         property $ do
           match <- forAll Gen.bool
           cover 30 "True" $ match
           cover 30 "False" $ not match

The example above requires a minimum of 30% coverage for both classifiers. If these requirements are not met, it will fail the test.

classify :: (MonadTest m, HasCallStack) => LabelName -> Bool -> m () Source #

Records the proportion of tests which satisfy a given condition.

       prop_with_classifier :: Property
       prop_with_classifier =
         property $ do
           xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
           for_ xs $ \x -> do
             classify "newborns" $ x == 0
             classify "children" $ x > 0 && x < 13
             classify "teens" $ x > 12 && x < 20

label :: (MonadTest m, HasCallStack) => LabelName -> m () Source #

Add a label for each test run. It produces a table showing the percentage of test runs that produced each label.

collect :: (MonadTest m, Show a, HasCallStack) => a -> m () Source #

Like `label`, but uses `Show` to render its argument for display.

coverPercentage :: TestCount -> CoverCount -> CoverPercentage Source #

labelCovered :: TestCount -> Label CoverCount -> Bool Source #

coverageSuccess :: TestCount -> Coverage CoverCount -> Bool Source #

All labels are covered

coverageFailures :: TestCount -> Coverage CoverCount -> [Label CoverCount] Source #

journalCoverage :: Journal -> Coverage CoverCount Source #

data Cover Source #

Whether a test is covered by a classifier, and therefore belongs to a `Class`.

Constructors

NoCover |
Cover |

#### Instances

Instances details

Monoid Cover Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mempty :: Cover Source # mappend :: Cover -> Cover -> Cover Source # mconcat :: [Cover] -> Cover Source #
Semigroup Cover Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: Cover -> Cover -> Cover Source # sconcat :: NonEmpty Cover -> Cover Source # stimes :: Integral b => b -> Cover -> Cover Source #
Show Cover Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Cover -> ShowS Source # show :: Cover -> String Source # showList :: [Cover] -> ShowS Source #
Eq Cover Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Cover -> Cover -> Bool Source # (/=) :: Cover -> Cover -> Bool Source #
Ord Cover Source # |
Instance details Defined in Hedgehog.Internal.Property Methods compare :: Cover -> Cover -> Ordering Source # (<) :: Cover -> Cover -> Bool Source # (<=) :: Cover -> Cover -> Bool Source # (>) :: Cover -> Cover -> Bool Source # (>=) :: Cover -> Cover -> Bool Source # max :: Cover -> Cover -> Cover Source # min :: Cover -> Cover -> Cover Source #

newtype CoverCount Source #

The total number of tests which are covered by a classifier.

Can be constructed using numeric literals:

      30 :: CoverCount

Constructors

CoverCount |

Fields

- unCoverCount :: Int

#### Instances

Instances details

Monoid CoverCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods mempty :: CoverCount Source # mappend :: CoverCount -> CoverCount -> CoverCount Source # mconcat :: [CoverCount] -> CoverCount Source #
Semigroup CoverCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (<>) :: CoverCount -> CoverCount -> CoverCount Source # sconcat :: NonEmpty CoverCount -> CoverCount Source # stimes :: Integral b => b -> CoverCount -> CoverCount Source #
Num CoverCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: CoverCount -> CoverCount -> CoverCount Source #

(-) :: CoverCount -> CoverCount -> CoverCount Source #

(*) :: CoverCount -> CoverCount -> CoverCount Source #

negate :: CoverCount -> CoverCount Source #

abs :: CoverCount -> CoverCount Source #

signum :: CoverCount -> CoverCount Source #

fromInteger :: Integer -> CoverCount Source #

Show CoverCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> CoverCount -> ShowS Source # show :: CoverCount -> String Source # showList :: [CoverCount] -> ShowS Source #
Eq CoverCount Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: CoverCount -> CoverCount -> Bool Source # (/=) :: CoverCount -> CoverCount -> Bool Source #
Ord CoverCount Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: CoverCount -> CoverCount -> Ordering Source #

(<) :: CoverCount -> CoverCount -> Bool Source #

(<=) :: CoverCount -> CoverCount -> Bool Source #

(>) :: CoverCount -> CoverCount -> Bool Source #

(>=) :: CoverCount -> CoverCount -> Bool Source #

max :: CoverCount -> CoverCount -> CoverCount Source #

min :: CoverCount -> CoverCount -> CoverCount Source #

newtype CoverPercentage Source #

The relative number of tests which are covered by a classifier.

Can be constructed using numeric literals:

      30 :: CoverPercentage

Constructors

CoverPercentage |

Fields

- unCoverPercentage :: Double

#### Instances

Instances details

Num CoverPercentage Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: CoverPercentage -> CoverPercentage -> CoverPercentage Source #

(-) :: CoverPercentage -> CoverPercentage -> CoverPercentage Source #

(*) :: CoverPercentage -> CoverPercentage -> CoverPercentage Source #

negate :: CoverPercentage -> CoverPercentage Source #

abs :: CoverPercentage -> CoverPercentage Source #

signum :: CoverPercentage -> CoverPercentage Source #

fromInteger :: Integer -> CoverPercentage Source #

Fractional CoverPercentage Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (/) :: CoverPercentage -> CoverPercentage -> CoverPercentage Source # recip :: CoverPercentage -> CoverPercentage Source # fromRational :: Rational -> CoverPercentage Source #
Show CoverPercentage Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> CoverPercentage -> ShowS Source # show :: CoverPercentage -> String Source # showList :: [CoverPercentage] -> ShowS Source #
Eq CoverPercentage Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: CoverPercentage -> CoverPercentage -> Bool Source # (/=) :: CoverPercentage -> CoverPercentage -> Bool Source #
Ord CoverPercentage Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: CoverPercentage -> CoverPercentage -> Ordering Source #

(<) :: CoverPercentage -> CoverPercentage -> Bool Source #

(<=) :: CoverPercentage -> CoverPercentage -> Bool Source #

(>) :: CoverPercentage -> CoverPercentage -> Bool Source #

(>=) :: CoverPercentage -> CoverPercentage -> Bool Source #

max :: CoverPercentage -> CoverPercentage -> CoverPercentage Source #

min :: CoverPercentage -> CoverPercentage -> CoverPercentage Source #

toCoverCount :: Cover -> CoverCount Source #

# Confidence

newtype Confidence Source #

The acceptable occurrence of false positives

Example, `Confidence 10^9` would mean that you'd accept a false positive for 1 in 10^9 tests.

Constructors

Confidence |

Fields

- unConfidence :: Int64

#### Instances

Instances details

Num Confidence Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

(+) :: Confidence -> Confidence -> Confidence Source #

(-) :: Confidence -> Confidence -> Confidence Source #

(*) :: Confidence -> Confidence -> Confidence Source #

negate :: Confidence -> Confidence Source #

abs :: Confidence -> Confidence Source #

signum :: Confidence -> Confidence Source #

fromInteger :: Integer -> Confidence Source #

Show Confidence Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> Confidence -> ShowS Source # show :: Confidence -> String Source # showList :: [Confidence] -> ShowS Source #
Eq Confidence Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: Confidence -> Confidence -> Bool Source # (/=) :: Confidence -> Confidence -> Bool Source #
Ord Confidence Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: Confidence -> Confidence -> Ordering Source #

(<) :: Confidence -> Confidence -> Bool Source #

(<=) :: Confidence -> Confidence -> Bool Source #

(>) :: Confidence -> Confidence -> Bool Source #

(>=) :: Confidence -> Confidence -> Bool Source #

max :: Confidence -> Confidence -> Confidence Source #

min :: Confidence -> Confidence -> Confidence Source #

Lift Confidence Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => Confidence -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Confidence -> Code m Confidence Source #

data TerminationCriteria Source #

Constructors

EarlyTermination Confidence TestLimit |
NoEarlyTermination Confidence TestLimit |
NoConfidenceTermination TestLimit |

#### Instances

Instances details

Show TerminationCriteria Source # |
Instance details Defined in Hedgehog.Internal.Property Methods showsPrec :: Int -> TerminationCriteria -> ShowS Source # show :: TerminationCriteria -> String Source # showList :: [TerminationCriteria] -> ShowS Source #
Eq TerminationCriteria Source # |
Instance details Defined in Hedgehog.Internal.Property Methods (==) :: TerminationCriteria -> TerminationCriteria -> Bool Source # (/=) :: TerminationCriteria -> TerminationCriteria -> Bool Source #
Ord TerminationCriteria Source # |

Instance details

Defined in Hedgehog.Internal.Property

Methods

compare :: TerminationCriteria -> TerminationCriteria -> Ordering Source #

(<) :: TerminationCriteria -> TerminationCriteria -> Bool Source #

(<=) :: TerminationCriteria -> TerminationCriteria -> Bool Source #

(>) :: TerminationCriteria -> TerminationCriteria -> Bool Source #

(>=) :: TerminationCriteria -> TerminationCriteria -> Bool Source #

max :: TerminationCriteria -> TerminationCriteria -> TerminationCriteria Source #

min :: TerminationCriteria -> TerminationCriteria -> TerminationCriteria Source #

Lift TerminationCriteria Source # |
Instance details Defined in Hedgehog.Internal.Property Methods lift :: Quote m => TerminationCriteria -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => TerminationCriteria -> Code m TerminationCriteria Source #

confidenceSuccess :: TestCount -> Confidence -> Coverage CoverCount -> Bool Source #

Is true when the test coverage satisfies the specified `Confidence` contstraint for all 'Coverage CoverCount's

confidenceFailure :: TestCount -> Confidence -> Coverage CoverCount -> Bool Source #

Is true when there exists a label that is sure to have failed according to the `Confidence` constraint

withConfidence :: Confidence -> Property -> Property Source #

Make sure that the result is statistically significant in accordance to the passed `Confidence`

verifiedTermination :: Property -> Property Source #

defaultConfidence :: Confidence Source #

The default confidence allows one false positive in 10^9 tests

# Internal

These functions are exported in case you need them in a pinch, but are not part of the public API and may change at any time, even as part of a minor update.

defaultConfig :: PropertyConfig Source #

The default configuration for a property test.

mapConfig :: (PropertyConfig -> PropertyConfig) -> Property -> Property Source #

Map a config modification function over a property.

failDiff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> b -> m () Source #

Fails with an error that shows the difference between two values.

failException :: (MonadTest m, HasCallStack) => SomeException -> m a Source #

Fails with an error which renders the type of an exception and its error message.

failWith :: (MonadTest m, HasCallStack) => Maybe Diff -> String -> m a Source #

Fail the test with an error message, useful for building other failure combinators.

writeLog :: MonadTest m => Log -> m () Source #

Log some information which might be relevant to a potential test failure.

mkTest :: (Either Failure a, Journal) -> Test a Source #

mkTestT :: m (Either Failure a, Journal) -> TestT m a Source #

runTest :: Test a -> (Either Failure a, Journal) Source #

runTestT :: TestT m a -> m (Either Failure a, Journal) Source #

wilsonBounds :: Integer -> Integer -> Double -> (Double, Double) Source #