QuickCheck-2.9.2: Automatic testing of Haskell programs

Safe Haskell | Safe
Language | Haskell98

Test.QuickCheck

Contents

- Running tests
  - Running tests verbosely
  - Testing all properties in a module
  - Testing polymorphic properties
- Random generation
  - Generator combinators
  - Generators which use Arbitrary
  - Running a generator
  - Generator debugging
- Arbitrary and CoArbitrary classes
  - Helper functions for implementing arbitrary
  - Helper functions for implementing shrink
  - Helper functions for implementing coarbitrary
  - Type-level modifiers for changing generator behavior
- Properties
  - Property combinators
    - Controlling property execution
    - Conjunction and disjunction
    - What to do on failure
    - Analysing test distribution
    - Miscellaneous

Description

For further information see the QuickCheck manual.

To use QuickCheck to check a property, first define a function expressing that property (functions expressing properties under test tend to be prefixed with `prop_`). Testing that `n + m = m + n` holds for `Integer`s one might write:

    import Test.QuickCheck

    prop_commutativeAdd :: Integer -> Integer -> Bool
    prop_commutativeAdd n m = n + m == m + n

and testing:

    >>> quickCheck prop_commutativeAdd
    +++ OK, passed 100 tests.

which tests `prop_commutativeAdd` on 100 random `(Integer, Integer)` pairs.

`verboseCheck` can be used to see the actual values generated:

    >>> verboseCheck prop_commutativeAdd
    Passed:
    0
    0
      …98 tests omitted…
    Passed:
    -68
    6
    +++ OK, passed 100 tests.

and if more than 100 tests are needed the number of tests can be increased by updating the `stdArgs` record:

    >>> quickCheckWith stdArgs { maxSuccess = 500 } prop_commutativeAdd
    +++ OK, passed 500 tests.

To let QuickCheck generate values of your own data type an `Arbitrary` instance must be defined:

    data Point = MkPoint Int Int deriving Eq

    instance Arbitrary Point where
      arbitrary = do
        x <- arbitrary
        y <- arbitrary
        return (MkPoint x y)

    swapPoint :: Point -> Point
    swapPoint (MkPoint x y) = MkPoint y x

    -- swapPoint . swapPoint = id
    prop_swapInvolution point = swapPoint (swapPoint point) == point

    >>> quickCheck prop_swapInvolution
    +++ OK, passed 100 tests.

See Test.QuickCheck.Function for generating random shrinkable, showable functions used for testing higher-order functions and Test.QuickCheck.Monadic for testing impure or monadic code (e.g. effectful code in `IO`).

Synopsis

- quickCheck :: Testable prop => prop -> IO ()
- data Args = Args {
  - replay :: Maybe (QCGen, Int)
  - maxSuccess :: Int
  - maxDiscardRatio :: Int
  - maxSize :: Int
  - chatty :: Bool
  }
- data Result
  - = Success {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | GaveUp {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | Failure {
    - numTests :: Int
    - numShrinks :: Int
    - numShrinkTries :: Int
    - numShrinkFinal :: Int
    - usedSeed :: QCGen
    - usedSize :: Int
    - reason :: String
    - theException :: Maybe AnException
    - labels :: [(String, Int)]
    - output :: String
    }
  - | NoExpectedFailure {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | InsufficientCoverage {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
- stdArgs :: Args
- quickCheckWith :: Testable prop => Args -> prop -> IO ()
- quickCheckWithResult :: Testable prop => Args -> prop -> IO Result
- quickCheckResult :: Testable prop => prop -> IO Result
- verboseCheck :: Testable prop => prop -> IO ()
- verboseCheckWith :: Testable prop => Args -> prop -> IO ()
- verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result
- verboseCheckResult :: Testable prop => prop -> IO Result
- quickCheckAll :: Q Exp
- verboseCheckAll :: Q Exp
- forAllProperties :: Q Exp
- polyQuickCheck :: Name -> ExpQ
- polyVerboseCheck :: Name -> ExpQ
- monomorphic :: Name -> ExpQ
- data Gen a
- choose :: Random a => (a, a) -> Gen a
- oneof :: [Gen a] -> Gen a
- frequency :: [(Int, Gen a)] -> Gen a
- elements :: [a] -> Gen a
- growingElements :: [a] -> Gen a
- sized :: (Int -> Gen a) -> Gen a
- resize :: Int -> Gen a -> Gen a
- scale :: (Int -> Int) -> Gen a -> Gen a
- suchThat :: Gen a -> (a -> Bool) -> Gen a
- suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
- listOf :: Gen a -> Gen [a]
- listOf1 :: Gen a -> Gen [a]
- vectorOf :: Int -> Gen a -> Gen [a]
- infiniteListOf :: Gen a -> Gen [a]
- shuffle :: [a] -> Gen [a]
- sublistOf :: [a] -> Gen [a]
- vector :: Arbitrary a => Int -> Gen [a]
- orderedList :: (Ord a, Arbitrary a) => Gen [a]
- infiniteList :: Arbitrary a => Gen [a]
- generate :: Gen a -> IO a
- sample :: Show a => Gen a -> IO ()
- sample' :: Gen a -> IO [a]
- class Arbitrary a where
- class CoArbitrary a where
- arbitrarySizedIntegral :: Integral a => Gen a
- arbitrarySizedNatural :: Integral a => Gen a
- arbitrarySizedFractional :: Fractional a => Gen a
- arbitrarySizedBoundedIntegral :: (Bounded a, Integral a) => Gen a
- arbitraryBoundedIntegral :: (Bounded a, Integral a) => Gen a
- arbitraryBoundedRandom :: (Bounded a, Random a) => Gen a
- arbitraryBoundedEnum :: (Bounded a, Enum a) => Gen a
- genericCoarbitrary :: (Generic a, GCoArbitrary (Rep a)) => a -> Gen b -> Gen b
- genericShrink :: (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) => a -> [a]
- subterms :: (Generic a, GSubterms (Rep a) a) => a -> [a]
- recursivelyShrink :: (Generic a, RecursivelyShrink (Rep a)) => a -> [a]
- shrinkNothing :: a -> [a]
- shrinkList :: (a -> [a]) -> [a] -> [[a]]
- shrinkIntegral :: Integral a => a -> [a]
- shrinkRealFrac :: RealFrac a => a -> [a]
- variant :: Integral n => n -> Gen a -> Gen a
- coarbitraryIntegral :: Integral a => a -> Gen b -> Gen b
- coarbitraryReal :: Real a => a -> Gen b -> Gen b
- coarbitraryShow :: Show a => a -> Gen b -> Gen b
- coarbitraryEnum :: Enum a => a -> Gen b -> Gen b
- (><) :: (Gen a -> Gen a) -> (Gen a -> Gen a) -> Gen a -> Gen a
- newtype Blind a = Blind {
  - getBlind :: a
  }
- newtype Fixed a = Fixed {
  - getFixed :: a
  }
- newtype OrderedList a = Ordered {
  - getOrdered :: [a]
  }
- newtype NonEmptyList a = NonEmpty {
  - getNonEmpty :: [a]
  }
- newtype Positive a = Positive {
  - getPositive :: a
  }
- newtype NonZero a = NonZero {
  - getNonZero :: a
  }
- newtype NonNegative a = NonNegative {
  - getNonNegative :: a
  }
- newtype Large a = Large {
  - getLarge :: a
  }
- newtype Small a = Small {
  - getSmall :: a
  }
- data Smart a = Smart Int a
- newtype Shrink2 a = Shrink2 {
  - getShrink2 :: a
  }
- data Shrinking s a = Shrinking s a
- class ShrinkState s a where
- data Property
- class Testable prop where
- forAll :: (Show a, Testable prop) => Gen a -> (a -> prop) -> Property
- forAllShrink :: (Show a, Testable prop) => Gen a -> (a -> [a]) -> (a -> prop) -> Property
- shrinking :: Testable prop => (a -> [a]) -> a -> (a -> prop) -> Property
- (==>) :: Testable prop => Bool -> prop -> Property
- (===) :: (Eq a, Show a) => a -> a -> Property
- ioProperty :: Testable prop => IO prop -> Property
- verbose :: Testable prop => prop -> Property
- once :: Testable prop => prop -> Property
- again :: Testable prop => prop -> Property
- within :: Testable prop => Int -> prop -> Property
- noShrinking :: Testable prop => prop -> Property
- (.&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- (.&&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- conjoin :: Testable prop => [prop] -> Property
- (.||.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- disjoin :: Testable prop => [prop] -> Property
- counterexample :: Testable prop => String -> prop -> Property
- printTestCase :: Testable prop => String -> prop -> Property
- whenFail :: Testable prop => IO () -> prop -> Property
- whenFail' :: Testable prop => IO () -> prop -> Property
- expectFailure :: Testable prop => prop -> Property
- label :: Testable prop => String -> prop -> Property
- collect :: (Show a, Testable prop) => a -> prop -> Property
- classify :: Testable prop => Bool -> String -> prop -> Property
- cover :: Testable prop => Bool -> Int -> String -> prop -> Property
- data Discard = Discard
- discard :: a
- mapSize :: Testable prop => (Int -> Int) -> prop -> Property

# Running tests

quickCheck :: Testable prop => prop -> IO () #

Tests a property and prints the results to `stdout`.

data Args #

Args specifies arguments to the QuickCheck driver

Constructors

Args |
Fields replay :: Maybe (QCGen, Int) Should we replay a previous test? Note: saving a seed from one version of QuickCheck and replaying it in another is not supported. If you want to store a test case permanently you should save the test case itself. maxSuccess :: Int Maximum number of successful tests before succeeding maxDiscardRatio :: Int Maximum number of discarded tests per successful test before giving up maxSize :: Int Size to use for the biggest test cases chatty :: Bool Whether to print anything

Instances

Read Args # |
Methods readsPrec :: Int -> ReadS Args # readList :: ReadS [Args] # readPrec :: ReadPrec Args # readListPrec :: ReadPrec [Args] #
Show Args # |
Methods showsPrec :: Int -> Args -> ShowS # show :: Args -> String # showList :: [Args] -> ShowS #

data Result #

Result represents the test result

Constructors

Success | A successful test run
Fields numTests :: Int Number of tests performed labels :: [(String, Int)] Labels and frequencies found during all successful tests output :: String Printed output
GaveUp | Given up
Fields numTests :: Int Number of tests performed labels :: [(String, Int)] Labels and frequencies found during all successful tests output :: String Printed output
Failure | A failed test run
Fields numTests :: Int Number of tests performed numShrinks :: Int Number of successful shrinking steps performed numShrinkTries :: Int Number of unsuccessful shrinking steps performed numShrinkFinal :: Int Number of unsuccessful shrinking steps performed since last successful shrink usedSeed :: QCGen What seed was used usedSize :: Int What was the test size reason :: String Why did the property fail theException :: Maybe AnException The exception the property threw, if any labels :: [(String, Int)] Labels and frequencies found during all successful tests output :: String Printed output
NoExpectedFailure | A property that should have failed did not
Fields numTests :: Int Number of tests performed labels :: [(String, Int)] Labels and frequencies found during all successful tests output :: String Printed output
InsufficientCoverage | The tests passed but a use of `cover` had insufficient coverage
Fields numTests :: Int Number of tests performed labels :: [(String, Int)] Labels and frequencies found during all successful tests output :: String Printed output

Instances

Show Result # |
Methods showsPrec :: Int -> Result -> ShowS # show :: Result -> String # showList :: [Result] -> ShowS #

stdArgs :: Args #

The default test arguments

quickCheckWith :: Testable prop => Args -> prop -> IO () #

Tests a property, using test arguments, and prints the results to `stdout`.

quickCheckWithResult :: Testable prop => Args -> prop -> IO Result #

Tests a property, using test arguments, produces a test result, and prints the results to `stdout`.

quickCheckResult :: Testable prop => prop -> IO Result #

Tests a property, produces a test result, and prints the results to `stdout`.

## Running tests verbosely

verboseCheck :: Testable prop => prop -> IO () #

Tests a property and prints the results and all test cases generated to `stdout`. This is just a convenience function that means the same as ``quickCheck` . `verbose``.

verboseCheckWith :: Testable prop => Args -> prop -> IO () #

Tests a property, using test arguments, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckWith` and `verbose`.

verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result #

Tests a property, using test arguments, produces a test result, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckWithResult` and `verbose`.

verboseCheckResult :: Testable prop => prop -> IO Result #

Tests a property, produces a test result, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckResult` and `verbose`.

## Testing all properties in a module

quickCheckAll :: Q Exp #

Test all properties in the current module. The name of the property must begin with `prop_`. Polymorphic properties will be defaulted to `Integer`. Returns `True` if all tests succeeded, `False` otherwise.

To use `quickCheckAll`, add a definition to your module along the lines of

    return []
    runTests = $quickCheckAll

and then execute `runTests`.

Note: the bizarre `return []` in the example above is needed on GHC 7.8; without it, `quickCheckAll` will not be able to find any of the properties. For the curious, the `return []` is a Template Haskell splice that makes GHC insert the empty list of declarations at that point in the program; GHC typechecks everything before the `return []` before it starts on the rest of the module, which means that the later call to `quickCheckAll` can see everything that was defined before the `return []`. Yikes!

verboseCheckAll :: Q Exp #

Test all properties in the current module. This is just a convenience function that combines `quickCheckAll` and `verbose`.

`verboseCheckAll` has the same issue with scoping as `quickCheckAll`: see the note there about `return []`.

forAllProperties :: Q Exp #

Test all properties in the current module, using a custom `quickCheck` function. The same caveats as with `quickCheckAll` apply.

`$`forAllProperties`` has type `(`Property` -> `IO` `Result`) -> `IO` `Bool``. An example invocation is `$`forAllProperties` `quickCheckResult``, which does the same thing as `$`quickCheckAll``.

`forAllProperties` has the same issue with scoping as `quickCheckAll`: see the note there about `return []`.

## Testing polymorphic properties

polyQuickCheck :: Name -> ExpQ #

Test a polymorphic property, defaulting all type variables to `Integer`.

Invoke as `$(`polyQuickCheck` 'prop)`, where `prop` is a property. Note that just evaluating ``quickCheck` prop` in GHCi will seem to work, but will silently default all type variables to `()`!

`$(`polyQuickCheck` 'prop)` means the same as ``quickCheck` $(`monomorphic` 'prop)`. If you want to supply custom arguments to `polyQuickCheck`, you will have to combine `quickCheckWith` and `monomorphic` yourself.

If you want to use `polyQuickCheck` in the same file where you defined the property, the same scoping problems pop up as in `quickCheckAll`: see the note there about `return []`.

polyVerboseCheck :: Name -> ExpQ #

Test a polymorphic property, defaulting all type variables to `Integer`. This is just a convenience function that combines `verboseCheck` and `monomorphic`.

If you want to use `polyVerboseCheck` in the same file where you defined the property, the same scoping problems pop up as in `quickCheckAll`: see the note there about `return []`.

monomorphic :: Name -> ExpQ #

Monomorphise an arbitrary property by defaulting all type variables to `Integer`.

For example, if `f` has type ``Ord` a => [a] -> [a]` then `$(`monomorphic` 'f)` has type `[`Integer`] -> [`Integer`]`.

If you want to use `monomorphic` in the same file where you defined the property, the same scoping problems pop up as in `quickCheckAll`: see the note there about `return []`.

# Random generation

data Gen a #

A generator for values of type `a`.

Instances

Monad Gen # |
Methods (>>=) :: Gen a -> (a -> Gen b) -> Gen b # (>>) :: Gen a -> Gen b -> Gen b # return :: a -> Gen a # fail :: String -> Gen a #
Functor Gen # |
Methods fmap :: (a -> b) -> Gen a -> Gen b # (<$) :: a -> Gen b -> Gen a #
Applicative Gen # |
Methods pure :: a -> Gen a # (<*>) :: Gen (a -> b) -> Gen a -> Gen b # (*>) :: Gen a -> Gen b -> Gen b # (<*) :: Gen a -> Gen b -> Gen a #
Testable prop => Testable (Gen prop) # |
Methods property :: Gen prop -> Property #

## Generator combinators

choose :: Random a => (a, a) -> Gen a #

Generates a random element in the given inclusive range.

oneof :: [Gen a] -> Gen a #

Randomly uses one of the given generators. The input list must be non-empty.

frequency :: [(Int, Gen a)] -> Gen a #

Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.

elements :: [a] -> Gen a #

Generates one of the given values. The input list must be non-empty.

growingElements :: [a] -> Gen a #

Takes a list of elements of increasing size, and chooses among an initial segment of the list. The size of this initial segment increases with the size parameter. The input list must be non-empty.

sized :: (Int -> Gen a) -> Gen a #

Used to construct generators that depend on the size parameter.

resize :: Int -> Gen a -> Gen a #

Overrides the size parameter. Returns a generator which uses the given size instead of the runtime-size parameter.

scale :: (Int -> Int) -> Gen a -> Gen a #

Adjust the size parameter, by transforming it with the given function.

suchThat :: Gen a -> (a -> Bool) -> Gen a #

Generates a value that satisfies a predicate.

suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a) #

Tries to generate a value that satisfies a predicate.

listOf :: Gen a -> Gen [a] #

Generates a list of random length. The maximum length depends on the size parameter.

listOf1 :: Gen a -> Gen [a] #

Generates a non-empty list of random length. The maximum length depends on the size parameter.

vectorOf :: Int -> Gen a -> Gen [a] #

Generates a list of the given length.

infiniteListOf :: Gen a -> Gen [a] #

Generates an infinite list.

shuffle :: [a] -> Gen [a] #

Generates a random permutation of the given list.

sublistOf :: [a] -> Gen [a] #

Generates a random subsequence of the given list.

## Generators which use Arbitrary

vector :: Arbitrary a => Int -> Gen [a] #

Generates a list of a given length.

orderedList :: (Ord a, Arbitrary a) => Gen [a] #

Generates an ordered list.

infiniteList :: Arbitrary a => Gen [a] #

Generate an infinite list.

## Running a generator

generate :: Gen a -> IO a #

Run a generator. The size passed to the generator is always 30; if you want another size then you should explicitly use `resize`.

## Generator debugging

sample :: Show a => Gen a -> IO () #

Generates some example values and prints them to `stdout`.

sample' :: Gen a -> IO [a] #

Generates some example values.

# Arbitrary and CoArbitrary classes

class Arbitrary a where #

Random generation and shrinking of values.

Minimal complete definition

arbitrary

Methods

arbitrary :: Gen a #

A generator for values of the given type.

shrink :: a -> [a] #

Produces a (possibly) empty list of all the possible immediate shrinks of the given value. The default implementation returns the empty list, so will not try to shrink the value.

Most implementations of `shrink` should try at least three things:

1. Shrink a term to any of its immediate subterms.
2. Recursively apply `shrink` to all immediate subterms.
3. Type-specific shrinkings such as replacing a constructor by a simpler constructor.

For example, suppose we have the following implementation of binary trees:

    data Tree a = Nil | Branch a (Tree a) (Tree a)

We can then define `shrink` as follows:

    shrink Nil = []
    shrink (Branch x l r) =
      -- shrink Branch to Nil
      [Nil] ++
      -- shrink to subterms
      [l, r] ++
      -- recursively shrink subterms
      [Branch x' l' r' | (x', l', r') <- shrink (x, l, r)]

There are a couple of subtleties here:

- QuickCheck tries the shrinking candidates in the order they appear in the list, so we put more aggressive shrinking steps (such as replacing the whole tree by `Nil`) before smaller ones (such as recursively shrinking the subtrees).
- It is tempting to write the last line as `[Branch x' l' r' | x' <- shrink x, l' <- shrink l, r' <- shrink r]` but this is the wrong thing! It will force QuickCheck to shrink `x`, `l` and `r` in tandem, and shrinking will stop once one of the three is fully shrunk.

There is a fair bit of boilerplate in the code above. We can avoid it with the help of some generic functions; note that these only work on GHC 7.2 and above. The function `genericShrink` tries shrinking a term to all of its subterms and, failing that, recursively shrinks the subterms. Using it, we can define `shrink` as:

    shrink x = shrinkToNil x ++ genericShrink x
      where
        shrinkToNil Nil = []
        shrinkToNil (Branch _ l r) = [Nil]

`genericShrink` is a combination of `subterms`, which shrinks a term to any of its subterms, and `recursivelyShrink`, which shrinks all subterms of a term. These may be useful if you need a bit more control over shrinking than `genericShrink` gives you.

A final gotcha: we cannot define `shrink` as simply ``shrink` x = Nil:`genericShrink` x` as this shrinks `Nil` to `Nil`, and shrinking will go into an infinite loop.

If all this leaves you bewildered, you might try ``shrink` = `genericShrink`` to begin with, after deriving `Generic` for your type. However, if your data type has any special invariants, you will need to check that `genericShrink` can't break those invariants.

Instances

Arbitrary Bool # |
Methods arbitrary :: Gen Bool # shrink :: Bool -> [Bool] #
Arbitrary Char # |
Methods arbitrary :: Gen Char # shrink :: Char -> [Char] #
Arbitrary Double # |
Methods arbitrary :: Gen Double # shrink :: Double -> [Double] #
Arbitrary Float # |
Methods arbitrary :: Gen Float # shrink :: Float -> [Float] #
Arbitrary Int # |
Methods arbitrary :: Gen Int # shrink :: Int -> [Int] #
Arbitrary Int8 # |
Methods arbitrary :: Gen Int8 # shrink :: Int8 -> [Int8] #
Arbitrary Int16 # |
Methods arbitrary :: Gen Int16 # shrink :: Int16 -> [Int16] #
Arbitrary Int32 # |
Methods arbitrary :: Gen Int32 # shrink :: Int32 -> [Int32] #
Arbitrary Int64 # |
Methods arbitrary :: Gen Int64 # shrink :: Int64 -> [Int64] #
Arbitrary Integer # |
Methods arbitrary :: Gen Integer # shrink :: Integer -> [Integer] #
Arbitrary Ordering # |
Methods arbitrary :: Gen Ordering # shrink :: Ordering -> [Ordering] #
Arbitrary Word # |
Methods arbitrary :: Gen Word # shrink :: Word -> [Word] #
Arbitrary Word8 # |
Methods arbitrary :: Gen Word8 # shrink :: Word8 -> [Word8] #
Arbitrary Word16 # |
Methods arbitrary :: Gen Word16 # shrink :: Word16 -> [Word16] #
Arbitrary Word32 # |
Methods arbitrary :: Gen Word32 # shrink :: Word32 -> [Word32] #
Arbitrary Word64 # |
Methods arbitrary :: Gen Word64 # shrink :: Word64 -> [Word64] #
Arbitrary () # |
Methods arbitrary :: Gen () # shrink :: () -> [()] #
Arbitrary Natural # |
Methods arbitrary :: Gen Natural # shrink :: Natural -> [Natural] #
Arbitrary Version # | Generates `Version` with non-empty non-negative `versionBranch`, and empty `versionTags`
Methods arbitrary :: Gen Version # shrink :: Version -> [Version] #
Arbitrary All # |
Methods arbitrary :: Gen All # shrink :: All -> [All] #
Arbitrary Any # |
Methods arbitrary :: Gen Any # shrink :: Any -> [Any] #
Arbitrary IntSet # |
Methods arbitrary :: Gen IntSet # shrink :: IntSet -> [IntSet] #
Arbitrary OrdC # |
Methods arbitrary :: Gen OrdC # shrink :: OrdC -> [OrdC] #
Arbitrary OrdB # |
Methods arbitrary :: Gen OrdB # shrink :: OrdB -> [OrdB] #
Arbitrary OrdA # |
Methods arbitrary :: Gen OrdA # shrink :: OrdA -> [OrdA] #
Arbitrary C # |
Methods arbitrary :: Gen C # shrink :: C -> [C] #
Arbitrary B # |
Methods arbitrary :: Gen B # shrink :: B -> [B] #
Arbitrary A # |
Methods arbitrary :: Gen A # shrink :: A -> [A] #
Arbitrary a => Arbitrary [a] # |
Methods arbitrary :: Gen [a] # shrink :: [a] -> [[a]] #
Arbitrary a => Arbitrary (Maybe a) # |
Methods arbitrary :: Gen (Maybe a) # shrink :: Maybe a -> [Maybe a] #
Integral a => Arbitrary (Ratio a) # |
Methods arbitrary :: Gen (Ratio a) # shrink :: Ratio a -> [Ratio a] #
Arbitrary a => Arbitrary (Identity a) # |
Methods arbitrary :: Gen (Identity a) # shrink :: Identity a -> [Identity a] #
Arbitrary a => Arbitrary (NonEmpty a) # |
Methods arbitrary :: Gen (NonEmpty a) # shrink :: NonEmpty a -> [NonEmpty a] #
HasResolution a => Arbitrary (Fixed a) # |
Methods arbitrary :: Gen (Fixed a) # shrink :: Fixed a -> [Fixed a] #
(RealFloat a, Arbitrary a) => Arbitrary (Complex a) # |
Methods arbitrary :: Gen (Complex a) # shrink :: Complex a -> [Complex a] #
Arbitrary a => Arbitrary (ZipList a) # |
Methods arbitrary :: Gen (ZipList a) # shrink :: ZipList a -> [ZipList a] #
Arbitrary a => Arbitrary (Dual a) # |
Methods arbitrary :: Gen (Dual a) # shrink :: Dual a -> [Dual a] #
(Arbitrary a, CoArbitrary a) => Arbitrary (Endo a) # |
Methods arbitrary :: Gen (Endo a) # shrink :: Endo a -> [Endo a] #
Arbitrary a => Arbitrary (Sum a) # |
Methods arbitrary :: Gen (Sum a) # shrink :: Sum a -> [Sum a] #
Arbitrary a => Arbitrary (Product a) # |
Methods arbitrary :: Gen (Product a) # shrink :: Product a -> [Product a] #
Arbitrary a => Arbitrary (First a) # |
Methods arbitrary :: Gen (First a) # shrink :: First a -> [First a] #
Arbitrary a => Arbitrary (Last a) # |
Methods arbitrary :: Gen (Last a) # shrink :: Last a -> [Last a] #
Arbitrary a => Arbitrary (Seq a) # |
Methods arbitrary :: Gen (Seq a) # shrink :: Seq a -> [Seq a] #
Arbitrary a => Arbitrary (IntMap a) # |
Methods arbitrary :: Gen (IntMap a) # shrink :: IntMap a -> [IntMap a] #
(Ord a, Arbitrary a) => Arbitrary (Set a) # |
Methods arbitrary :: Gen (Set a) # shrink :: Set a -> [Set a] #
Arbitrary a => Arbitrary (Smart a) # |
Methods arbitrary :: Gen (Smart a) # shrink :: Smart a -> [Smart a] #
Arbitrary a => Arbitrary (Shrink2 a) # |
Methods arbitrary :: Gen (Shrink2 a) # shrink :: Shrink2 a -> [Shrink2 a] #
Integral a => Arbitrary (Small a) # |
Methods arbitrary :: Gen (Small a) # shrink :: Small a -> [Small a] #
(Integral a, Bounded a) => Arbitrary (Large a) # |
Methods arbitrary :: Gen (Large a) # shrink :: Large a -> [Large a] #
(Num a, Ord a, Arbitrary a) => Arbitrary (NonNegative a) # |
Methods arbitrary :: Gen (NonNegative a) # shrink :: NonNegative a -> [NonNegative a] #
(Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) # |
Methods arbitrary :: Gen (NonZero a) # shrink :: NonZero a -> [NonZero a] #
(Num a, Ord a, Arbitrary a) => Arbitrary (Positive a) # |
Methods arbitrary :: Gen (Positive a) # shrink :: Positive a -> [Positive a] #
Arbitrary a => Arbitrary (NonEmptyList a) # |
Methods arbitrary :: Gen (NonEmptyList a) # shrink :: NonEmptyList a -> [NonEmptyList a] #
(Ord a, Arbitrary a) => Arbitrary (OrderedList a) # |
Methods arbitrary :: Gen (OrderedList a) # shrink :: OrderedList a -> [OrderedList a] #
Arbitrary a => Arbitrary (Fixed a) # |
Methods arbitrary :: Gen (Fixed a) # shrink :: Fixed a -> [Fixed a] #
Arbitrary a => Arbitrary (Blind a) # |
Methods arbitrary :: Gen (Blind a) # shrink :: Blind a -> [Blind a] #
(CoArbitrary a, Arbitrary b) => Arbitrary (a -> b) # |
Methods arbitrary :: Gen (a -> b) # shrink :: (a -> b) -> [a -> b] #
(Arbitrary a, Arbitrary b) => Arbitrary (Either a b) # |
Methods arbitrary :: Gen (Either a b) # shrink :: Either a b -> [Either a b] #
(Arbitrary a, Arbitrary b) => Arbitrary (a, b) # |
Methods arbitrary :: Gen (a, b) # shrink :: (a, b) -> [(a, b)] #
(Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Map k v) # |
Methods arbitrary :: Gen (Map k v) # shrink :: Map k v -> [Map k v] #
(Arbitrary a, ShrinkState s a) => Arbitrary (Shrinking s a) # |
Methods arbitrary :: Gen (Shrinking s a) # shrink :: Shrinking s a -> [Shrinking s a] #
(Function a, CoArbitrary a, Arbitrary b) => Arbitrary (Fun a b) # |
Methods arbitrary :: Gen (Fun a b) # shrink :: Fun a b -> [Fun a b] #
(Function a, CoArbitrary a, Arbitrary b) => Arbitrary ((:->) a b) # |
Methods arbitrary :: Gen (a :-> b) # shrink :: (a :-> b) -> [a :-> b] #
(Arbitrary a, Arbitrary b, Arbitrary c) => Arbitrary (a, b, c) # |
Methods arbitrary :: Gen (a, b, c) # shrink :: (a, b, c) -> [(a, b, c)] #
Arbitrary a => Arbitrary (Const * a b) # |
Methods arbitrary :: Gen (Const * a b) # shrink :: Const * a b -> [Const * a b] #
Arbitrary (f a) => Arbitrary (Alt * f a) # |
Methods arbitrary :: Gen (Alt * f a) # shrink :: Alt * f a -> [Alt * f a] #
Arbitrary a => Arbitrary (Constant * a b) # |
Methods arbitrary :: Gen (Constant * a b) # shrink :: Constant * a b -> [Constant * a b] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => Arbitrary (a, b, c, d) # |
Methods arbitrary :: Gen (a, b, c, d) # shrink :: (a, b, c, d) -> [(a, b, c, d)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e) => Arbitrary (a, b, c, d, e) # |
Methods arbitrary :: Gen (a, b, c, d, e) # shrink :: (a, b, c, d, e) -> [(a, b, c, d, e)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f) => Arbitrary (a, b, c, d, e, f) # |
Methods arbitrary :: Gen (a, b, c, d, e, f) # shrink :: (a, b, c, d, e, f) -> [(a, b, c, d, e, f)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f, Arbitrary g) => Arbitrary (a, b, c, d, e, f, g) # |
Methods arbitrary :: Gen (a, b, c, d, e, f, g) # shrink :: (a, b, c, d, e, f, g) -> [(a, b, c, d, e, f, g)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f, Arbitrary g, Arbitrary h) => Arbitrary (a, b, c, d, e, f, g, h) # |
Methods arbitrary :: Gen (a, b, c, d, e, f, g, h) # shrink :: (a, b, c, d, e, f, g, h) -> [(a, b, c, d, e, f, g, h)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f, Arbitrary g, Arbitrary h, Arbitrary i) => Arbitrary (a, b, c, d, e, f, g, h, i) # |
Methods arbitrary :: Gen (a, b, c, d, e, f, g, h, i) # shrink :: (a, b, c, d, e, f, g, h, i) -> [(a, b, c, d, e, f, g, h, i)] #
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f, Arbitrary g, Arbitrary h, Arbitrary i, Arbitrary j) => Arbitrary (a, b, c, d, e, f, g, h, i, j) # |
Methods arbitrary :: Gen (a, b, c, d, e, f, g, h, i, j) # shrink :: (a, b, c, d, e, f, g, h, i, j) -> [(a, b, c, d, e, f, g, h, i, j)] #

class CoArbitrary a where #

Used for random generation of functions.

If you are using a recent GHC, there is a default definition of `coarbitrary` using `genericCoarbitrary`, so if your type has a `Generic` instance it's enough to say

    instance CoArbitrary MyType

You should only use `genericCoarbitrary` for data types where equality is structural, i.e. if you can't have two different representations of the same value. An example where it's not safe is sets implemented using binary search trees: the same set can be represented as several different trees. Here you would have to explicitly define `coarbitrary s = coarbitrary (toList s)`.

Methods

coarbitrary :: a -> Gen b -> Gen b #

Used to generate a function of type `a -> b`. The first argument is a value, the second a generator. You should use `variant` to perturb the random generator; the goal is that different values for the first argument will lead to different calls to `variant`. An example will help:

    instance CoArbitrary a => CoArbitrary [a] where
      coarbitrary []     = variant 0
      coarbitrary (x:xs) = variant 1 . coarbitrary (x,xs)

coarbitrary :: (Generic a, GCoArbitrary (Rep a)) => a -> Gen b -> Gen b #

Used to generate a function of type `a -> b`. The first argument is a value, the second a generator. You should use `variant` to perturb the random generator; the goal is that different values for the first argument will lead to different calls to `variant`. An example will help:

    instance CoArbitrary a => CoArbitrary [a] where
      coarbitrary []     = variant 0
      coarbitrary (x:xs) = variant 1 . coarbitrary (x,xs)

Instances

CoArbitrary Bool # |
Methods coarbitrary :: Bool -> Gen b -> Gen b #
CoArbitrary Char # |
Methods coarbitrary :: Char -> Gen b -> Gen b #
CoArbitrary Double # |
Methods coarbitrary :: Double -> Gen b -> Gen b #
CoArbitrary Float # |
Methods coarbitrary :: Float -> Gen b -> Gen b #
CoArbitrary Int # |
Methods coarbitrary :: Int -> Gen b -> Gen b #
CoArbitrary Int8 # |
Methods coarbitrary :: Int8 -> Gen b -> Gen b #
CoArbitrary Int16 # |
Methods coarbitrary :: Int16 -> Gen b -> Gen b #
CoArbitrary Int32 # |
Methods coarbitrary :: Int32 -> Gen b -> Gen b #
CoArbitrary Int64 # |
Methods coarbitrary :: Int64 -> Gen b -> Gen b #
CoArbitrary Integer # |
Methods coarbitrary :: Integer -> Gen b -> Gen b #
CoArbitrary Ordering # |
Methods coarbitrary :: Ordering -> Gen b -> Gen b #
CoArbitrary Word # |
Methods coarbitrary :: Word -> Gen b -> Gen b #
CoArbitrary Word8 # |
Methods coarbitrary :: Word8 -> Gen b -> Gen b #
CoArbitrary Word16 # |
Methods coarbitrary :: Word16 -> Gen b -> Gen b #
CoArbitrary Word32 # |
Methods coarbitrary :: Word32 -> Gen b -> Gen b #
CoArbitrary Word64 # |
Methods coarbitrary :: Word64 -> Gen b -> Gen b #
CoArbitrary () # |
Methods coarbitrary :: () -> Gen b -> Gen b #
CoArbitrary Natural # |
Methods coarbitrary :: Natural -> Gen b -> Gen b #
CoArbitrary Version # |
Methods coarbitrary :: Version -> Gen b -> Gen b #
CoArbitrary All # |
Methods coarbitrary :: All -> Gen b -> Gen b #
CoArbitrary Any # |
Methods coarbitrary :: Any -> Gen b -> Gen b #
CoArbitrary IntSet # |
Methods coarbitrary :: IntSet -> Gen b -> Gen b #
CoArbitrary OrdC # |
Methods coarbitrary :: OrdC -> Gen b -> Gen b #
CoArbitrary OrdB # |
Methods coarbitrary :: OrdB -> Gen b -> Gen b #
CoArbitrary OrdA # |
Methods coarbitrary :: OrdA -> Gen b -> Gen b #
CoArbitrary C # |
Methods coarbitrary :: C -> Gen b -> Gen b #
CoArbitrary B # |
Methods coarbitrary :: B -> Gen b -> Gen b #
CoArbitrary A # |
Methods coarbitrary :: A -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary [a] # |
Methods coarbitrary :: [a] -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Maybe a) # |
Methods coarbitrary :: Maybe a -> Gen b -> Gen b #
(Integral a, CoArbitrary a) => CoArbitrary (Ratio a) # |
Methods coarbitrary :: Ratio a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Identity a) # |
Methods coarbitrary :: Identity a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (NonEmpty a) # |
Methods coarbitrary :: NonEmpty a -> Gen b -> Gen b #
HasResolution a => CoArbitrary (Fixed a) # |
Methods coarbitrary :: Fixed a -> Gen b -> Gen b #
(RealFloat a, CoArbitrary a) => CoArbitrary (Complex a) # |
Methods coarbitrary :: Complex a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (ZipList a) # |
Methods coarbitrary :: ZipList a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Dual a) # |
Methods coarbitrary :: Dual a -> Gen b -> Gen b #
(Arbitrary a, CoArbitrary a) => CoArbitrary (Endo a) # |
Methods coarbitrary :: Endo a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Sum a) # |
Methods coarbitrary :: Sum a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Product a) # |
Methods coarbitrary :: Product a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (First a) # |
Methods coarbitrary :: First a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Last a) # |
Methods coarbitrary :: Last a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Seq a) # |
Methods coarbitrary :: Seq a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (IntMap a) # |
Methods coarbitrary :: IntMap a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Set a) # |
Methods coarbitrary :: Set a -> Gen b -> Gen b #
(Arbitrary a, CoArbitrary b) => CoArbitrary (a -> b) # |
Methods coarbitrary :: (a -> b) -> Gen b -> Gen b #
(CoArbitrary a, CoArbitrary b) => CoArbitrary (Either a b) # |
Methods coarbitrary :: Either a b -> Gen b -> Gen b #
(CoArbitrary a, CoArbitrary b) => CoArbitrary (a, b) # |
Methods coarbitrary :: (a, b) -> Gen b -> Gen b #
(CoArbitrary k, CoArbitrary v) => CoArbitrary (Map k v) # |
Methods coarbitrary :: Map k v -> Gen b -> Gen b #
(CoArbitrary a, CoArbitrary b, CoArbitrary c) => CoArbitrary (a, b, c) # |
Methods coarbitrary :: (a, b, c) -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Const * a b) # |
Methods coarbitrary :: Const * a b -> Gen b -> Gen b #
CoArbitrary (f a) => CoArbitrary (Alt * f a) # |
Methods coarbitrary :: Alt * f a -> Gen b -> Gen b #
CoArbitrary a => CoArbitrary (Constant * a b) # |
Methods coarbitrary :: Constant * a b -> Gen b -> Gen b #
(CoArbitrary a, CoArbitrary b, CoArbitrary c, CoArbitrary d) => CoArbitrary (a, b, c, d) # |
Methods coarbitrary :: (a, b, c, d) -> Gen b -> Gen b #
(CoArbitrary a, CoArbitrary b, CoArbitrary c, CoArbitrary d, CoArbitrary e) => CoArbitrary (a, b, c, d, e) # |
Methods coarbitrary :: (a, b, c, d, e) -> Gen b -> Gen b #

## Helper functions for implementing arbitrary

arbitrarySizedIntegral :: Integral a => Gen a #

Generates an integral number. The number can be positive or negative and its maximum absolute value depends on the size parameter.

arbitrarySizedNatural :: Integral a => Gen a #

Generates a natural number. The number's maximum value depends on the size parameter.

arbitrarySizedFractional :: Fractional a => Gen a #

Generates a fractional number. The number can be positive or negative and its maximum absolute value depends on the size parameter.

arbitrarySizedBoundedIntegral :: (Bounded a, Integral a) => Gen a #

Generates an integral number from a bounded domain. The number is chosen from the entire range of the type, but small numbers are generated more often than big numbers. Inspired by demands from Phil Wadler.

arbitraryBoundedIntegral :: (Bounded a, Integral a) => Gen a #

Generates an integral number. The number is chosen uniformly from the entire range of the type. You may want to use `arbitrarySizedBoundedIntegral` instead.

arbitraryBoundedRandom :: (Bounded a, Random a) => Gen a #

Generates an element of a bounded type. The element is chosen from the entire range of the type.

arbitraryBoundedEnum :: (Bounded a, Enum a) => Gen a #

Generates an element of a bounded enumeration.

## Helper functions for implementing shrink

genericCoarbitrary :: (Generic a, GCoArbitrary (Rep a)) => a -> Gen b -> Gen b #

Generic CoArbitrary implementation.

genericShrink :: (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) => a -> [a] #

Shrink a term to any of its immediate subterms, and also recursively shrink all subterms.

subterms :: (Generic a, GSubterms (Rep a) a) => a -> [a] #

All immediate subterms of a term.

recursivelyShrink :: (Generic a, RecursivelyShrink (Rep a)) => a -> [a] #

Recursively shrink all immediate subterms.

shrinkNothing :: a -> [a] #

Returns no shrinking alternatives.

shrinkList :: (a -> [a]) -> [a] -> [[a]] #

Shrink a list of values given a shrinking function for individual values.

shrinkIntegral :: Integral a => a -> [a] #

Shrink an integral number.

shrinkRealFrac :: RealFrac a => a -> [a] #

Shrink a fraction.

## Helper functions for implementing coarbitrary

variant :: Integral n => n -> Gen a -> Gen a #

Modifies a generator using an integer seed.

coarbitraryIntegral :: Integral a => a -> Gen b -> Gen b #

A `coarbitrary` implementation for integral numbers.

coarbitraryReal :: Real a => a -> Gen b -> Gen b #

A `coarbitrary` implementation for real numbers.

coarbitraryShow :: Show a => a -> Gen b -> Gen b #

`coarbitrary` helper for lazy people :-).

coarbitraryEnum :: Enum a => a -> Gen b -> Gen b #

A `coarbitrary` implementation for enums.

(><) :: (Gen a -> Gen a) -> (Gen a -> Gen a) -> Gen a -> Gen a #

Deprecated: Use ordinary function composition instead

Combine two generator perturbing functions, for example the results of calls to `variant` or `coarbitrary`.

## Type-level modifiers for changing generator behavior

newtype Blind a #

`Blind x`: as x, but x does not have to be in the `Show` class.

Constructors

Blind |
Fields getBlind :: a

Instances

Functor Blind # |
Methods fmap :: (a -> b) -> Blind a -> Blind b # (<$) :: a -> Blind b -> Blind a #
Enum a => Enum (Blind a) # |
Methods succ :: Blind a -> Blind a # pred :: Blind a -> Blind a # toEnum :: Int -> Blind a # fromEnum :: Blind a -> Int # enumFrom :: Blind a -> [Blind a] # enumFromThen :: Blind a -> Blind a -> [Blind a] # enumFromTo :: Blind a -> Blind a -> [Blind a] # enumFromThenTo :: Blind a -> Blind a -> Blind a -> [Blind a] #
Eq a => Eq (Blind a) # |
Methods (==) :: Blind a -> Blind a -> Bool # (/=) :: Blind a -> Blind a -> Bool #
Integral a => Integral (Blind a) # |
Methods quot :: Blind a -> Blind a -> Blind a # rem :: Blind a -> Blind a -> Blind a # div :: Blind a -> Blind a -> Blind a # mod :: Blind a -> Blind a -> Blind a # quotRem :: Blind a -> Blind a -> (Blind a, Blind a) # divMod :: Blind a -> Blind a -> (Blind a, Blind a) # toInteger :: Blind a -> Integer #
Num a => Num (Blind a) # |
Methods (+) :: Blind a -> Blind a -> Blind a # (-) :: Blind a -> Blind a -> Blind a # (*) :: Blind a -> Blind a -> Blind a # negate :: Blind a -> Blind a # abs :: Blind a -> Blind a # signum :: Blind a -> Blind a # fromInteger :: Integer -> Blind a #
Ord a => Ord (Blind a) # |
Methods compare :: Blind a -> Blind a -> Ordering # (<) :: Blind a -> Blind a -> Bool # (<=) :: Blind a -> Blind a -> Bool # (>) :: Blind a -> Blind a -> Bool # (>=) :: Blind a -> Blind a -> Bool # max :: Blind a -> Blind a -> Blind a # min :: Blind a -> Blind a -> Blind a #
Real a => Real (Blind a) # |
Methods toRational :: Blind a -> Rational #
Show (Blind a) # |
Methods showsPrec :: Int -> Blind a -> ShowS # show :: Blind a -> String # showList :: [Blind a] -> ShowS #
Arbitrary a => Arbitrary (Blind a) # |
Methods arbitrary :: Gen (Blind a) # shrink :: Blind a -> [Blind a] #

newtype Fixed a #

`Fixed x`: as x, but will not be shrunk.

Constructors

Fixed |
Fields getFixed :: a

Instances

Functor Fixed # |
Methods fmap :: (a -> b) -> Fixed a -> Fixed b # (<$) :: a -> Fixed b -> Fixed a #
Enum a => Enum (Fixed a) # |
Methods succ :: Fixed a -> Fixed a # pred :: Fixed a -> Fixed a # toEnum :: Int -> Fixed a # fromEnum :: Fixed a -> Int # enumFrom :: Fixed a -> [Fixed a] # enumFromThen :: Fixed a -> Fixed a -> [Fixed a] # enumFromTo :: Fixed a -> Fixed a -> [Fixed a] # enumFromThenTo :: Fixed a -> Fixed a -> Fixed a -> [Fixed a] #
Eq a => Eq (Fixed a) # |
Methods (==) :: Fixed a -> Fixed a -> Bool # (/=) :: Fixed a -> Fixed a -> Bool #
Integral a => Integral (Fixed a) # |
Methods quot :: Fixed a -> Fixed a -> Fixed a # rem :: Fixed a -> Fixed a -> Fixed a # div :: Fixed a -> Fixed a -> Fixed a # mod :: Fixed a -> Fixed a -> Fixed a # quotRem :: Fixed a -> Fixed a -> (Fixed a, Fixed a) # divMod :: Fixed a -> Fixed a -> (Fixed a, Fixed a) # toInteger :: Fixed a -> Integer #
Num a => Num (Fixed a) # |
Methods (+) :: Fixed a -> Fixed a -> Fixed a # (-) :: Fixed a -> Fixed a -> Fixed a # (*) :: Fixed a -> Fixed a -> Fixed a # negate :: Fixed a -> Fixed a # abs :: Fixed a -> Fixed a # signum :: Fixed a -> Fixed a # fromInteger :: Integer -> Fixed a #
Ord a => Ord (Fixed a) # |
Methods compare :: Fixed a -> Fixed a -> Ordering # (<) :: Fixed a -> Fixed a -> Bool # (<=) :: Fixed a -> Fixed a -> Bool # (>) :: Fixed a -> Fixed a -> Bool # (>=) :: Fixed a -> Fixed a -> Bool # max :: Fixed a -> Fixed a -> Fixed a # min :: Fixed a -> Fixed a -> Fixed a #
Read a => Read (Fixed a) # |
Methods readsPrec :: Int -> ReadS (Fixed a) # readList :: ReadS [Fixed a] # readPrec :: ReadPrec (Fixed a) # readListPrec :: ReadPrec [Fixed a] #
Real a => Real (Fixed a) # |
Methods toRational :: Fixed a -> Rational #
Show a => Show (Fixed a) # |
Methods showsPrec :: Int -> Fixed a -> ShowS # show :: Fixed a -> String # showList :: [Fixed a] -> ShowS #
Arbitrary a => Arbitrary (Fixed a) # |
Methods arbitrary :: Gen (Fixed a) # shrink :: Fixed a -> [Fixed a] #

newtype OrderedList a #

`Ordered xs`: guarantees that xs is ordered.

Constructors

Ordered |
Fields getOrdered :: [a]

Instances

Functor OrderedList # |
Methods fmap :: (a -> b) -> OrderedList a -> OrderedList b # (<$) :: a -> OrderedList b -> OrderedList a #
Eq a => Eq (OrderedList a) # |
Methods (==) :: OrderedList a -> OrderedList a -> Bool # (/=) :: OrderedList a -> OrderedList a -> Bool #
Ord a => Ord (OrderedList a) # |
Methods compare :: OrderedList a -> OrderedList a -> Ordering # (<) :: OrderedList a -> OrderedList a -> Bool # (<=) :: OrderedList a -> OrderedList a -> Bool # (>) :: OrderedList a -> OrderedList a -> Bool # (>=) :: OrderedList a -> OrderedList a -> Bool # max :: OrderedList a -> OrderedList a -> OrderedList a # min :: OrderedList a -> OrderedList a -> OrderedList a #
Read a => Read (OrderedList a) # |
Methods readsPrec :: Int -> ReadS (OrderedList a) # readList :: ReadS [OrderedList a] # readPrec :: ReadPrec (OrderedList a) # readListPrec :: ReadPrec [OrderedList a] #
Show a => Show (OrderedList a) # |
Methods showsPrec :: Int -> OrderedList a -> ShowS # show :: OrderedList a -> String # showList :: [OrderedList a] -> ShowS #
(Ord a, Arbitrary a) => Arbitrary (OrderedList a) # |
Methods arbitrary :: Gen (OrderedList a) # shrink :: OrderedList a -> [OrderedList a] #

newtype NonEmptyList a #

`NonEmpty xs`: guarantees that xs is non-empty.

Constructors

NonEmpty |
Fields getNonEmpty :: [a]

Instances

Functor NonEmptyList # |
Methods fmap :: (a -> b) -> NonEmptyList a -> NonEmptyList b # (<$) :: a -> NonEmptyList b -> NonEmptyList a #
Eq a => Eq (NonEmptyList a) # |
Methods (==) :: NonEmptyList a -> NonEmptyList a -> Bool # (/=) :: NonEmptyList a -> NonEmptyList a -> Bool #
Ord a => Ord (NonEmptyList a) # |
Methods compare :: NonEmptyList a -> NonEmptyList a -> Ordering # (<) :: NonEmptyList a -> NonEmptyList a -> Bool # (<=) :: NonEmptyList a -> NonEmptyList a -> Bool # (>) :: NonEmptyList a -> NonEmptyList a -> Bool # (>=) :: NonEmptyList a -> NonEmptyList a -> Bool # max :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a # min :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a #
Read a => Read (NonEmptyList a) # |
Methods readsPrec :: Int -> ReadS (NonEmptyList a) # readList :: ReadS [NonEmptyList a] # readPrec :: ReadPrec (NonEmptyList a) # readListPrec :: ReadPrec [NonEmptyList a] #
Show a => Show (NonEmptyList a) # |
Methods showsPrec :: Int -> NonEmptyList a -> ShowS # show :: NonEmptyList a -> String # showList :: [NonEmptyList a] -> ShowS #
Arbitrary a => Arbitrary (NonEmptyList a) # |
Methods arbitrary :: Gen (NonEmptyList a) # shrink :: NonEmptyList a -> [NonEmptyList a] #

newtype Positive a #

`Positive x`: guarantees that `x > 0`.

Constructors

Positive |
Fields getPositive :: a

Instances

Functor Positive # |
Methods fmap :: (a -> b) -> Positive a -> Positive b # (<$) :: a -> Positive b -> Positive a #
Enum a => Enum (Positive a) # |
Methods succ :: Positive a -> Positive a # pred :: Positive a -> Positive a # toEnum :: Int -> Positive a # fromEnum :: Positive a -> Int # enumFrom :: Positive a -> [Positive a] # enumFromThen :: Positive a -> Positive a -> [Positive a] # enumFromTo :: Positive a -> Positive a -> [Positive a] # enumFromThenTo :: Positive a -> Positive a -> Positive a -> [Positive a] #
Eq a => Eq (Positive a) # |
Methods (==) :: Positive a -> Positive a -> Bool # (/=) :: Positive a -> Positive a -> Bool #
Ord a => Ord (Positive a) # |
Methods compare :: Positive a -> Positive a -> Ordering # (<) :: Positive a -> Positive a -> Bool # (<=) :: Positive a -> Positive a -> Bool # (>) :: Positive a -> Positive a -> Bool # (>=) :: Positive a -> Positive a -> Bool # max :: Positive a -> Positive a -> Positive a # min :: Positive a -> Positive a -> Positive a #
Read a => Read (Positive a) # |
Methods readsPrec :: Int -> ReadS (Positive a) # readList :: ReadS [Positive a] # readPrec :: ReadPrec (Positive a) # readListPrec :: ReadPrec [Positive a] #
Show a => Show (Positive a) # |
Methods showsPrec :: Int -> Positive a -> ShowS # show :: Positive a -> String # showList :: [Positive a] -> ShowS #
(Num a, Ord a, Arbitrary a) => Arbitrary (Positive a) # |
Methods arbitrary :: Gen (Positive a) # shrink :: Positive a -> [Positive a] #

newtype NonZero a #

`NonZero x`: guarantees that `x /= 0`.

Constructors

NonZero |
Fields getNonZero :: a

Instances

Functor NonZero # |
Methods fmap :: (a -> b) -> NonZero a -> NonZero b # (<$) :: a -> NonZero b -> NonZero a #
Enum a => Enum (NonZero a) # |
Methods succ :: NonZero a -> NonZero a # pred :: NonZero a -> NonZero a # toEnum :: Int -> NonZero a # fromEnum :: NonZero a -> Int # enumFrom :: NonZero a -> [NonZero a] # enumFromThen :: NonZero a -> NonZero a -> [NonZero a] # enumFromTo :: NonZero a -> NonZero a -> [NonZero a] # enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a] #
Eq a => Eq (NonZero a) # |
Methods (==) :: NonZero a -> NonZero a -> Bool # (/=) :: NonZero a -> NonZero a -> Bool #
Ord a => Ord (NonZero a) # |
Methods compare :: NonZero a -> NonZero a -> Ordering # (<) :: NonZero a -> NonZero a -> Bool # (<=) :: NonZero a -> NonZero a -> Bool # (>) :: NonZero a -> NonZero a -> Bool # (>=) :: NonZero a -> NonZero a -> Bool # max :: NonZero a -> NonZero a -> NonZero a # min :: NonZero a -> NonZero a -> NonZero a #
Read a => Read (NonZero a) # |
Methods readsPrec :: Int -> ReadS (NonZero a) # readList :: ReadS [NonZero a] # readPrec :: ReadPrec (NonZero a) # readListPrec :: ReadPrec [NonZero a] #
Show a => Show (NonZero a) # |
Methods showsPrec :: Int -> NonZero a -> ShowS # show :: NonZero a -> String # showList :: [NonZero a] -> ShowS #
(Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) # |
Methods arbitrary :: Gen (NonZero a) # shrink :: NonZero a -> [NonZero a] #

newtype NonNegative a #

`NonNegative x`: guarantees that `x >= 0`.

Constructors

NonNegative |
Fields getNonNegative :: a

Instances

Functor NonNegative # |
Methods fmap :: (a -> b) -> NonNegative a -> NonNegative b # (<$) :: a -> NonNegative b -> NonNegative a #
Enum a => Enum (NonNegative a) # |
Methods succ :: NonNegative a -> NonNegative a # pred :: NonNegative a -> NonNegative a # toEnum :: Int -> NonNegative a # fromEnum :: NonNegative a -> Int # enumFrom :: NonNegative a -> [NonNegative a] # enumFromThen :: NonNegative a -> NonNegative a -> [NonNegative a] # enumFromTo :: NonNegative a -> NonNegative a -> [NonNegative a] # enumFromThenTo :: NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a] #
Eq a => Eq (NonNegative a) # |
Methods (==) :: NonNegative a -> NonNegative a -> Bool # (/=) :: NonNegative a -> NonNegative a -> Bool #
Ord a => Ord (NonNegative a) # |
Methods compare :: NonNegative a -> NonNegative a -> Ordering # (<) :: NonNegative a -> NonNegative a -> Bool # (<=) :: NonNegative a -> NonNegative a -> Bool # (>) :: NonNegative a -> NonNegative a -> Bool # (>=) :: NonNegative a -> NonNegative a -> Bool # max :: NonNegative a -> NonNegative a -> NonNegative a # min :: NonNegative a -> NonNegative a -> NonNegative a #
Read a => Read (NonNegative a) # |
Methods readsPrec :: Int -> ReadS (NonNegative a) # readList :: ReadS [NonNegative a] # readPrec :: ReadPrec (NonNegative a) # readListPrec :: ReadPrec [NonNegative a] #
Show a => Show (NonNegative a) # |
Methods showsPrec :: Int -> NonNegative a -> ShowS # show :: NonNegative a -> String # showList :: [NonNegative a] -> ShowS #
(Num a, Ord a, Arbitrary a) => Arbitrary (NonNegative a) # |
Methods arbitrary :: Gen (NonNegative a) # shrink :: NonNegative a -> [NonNegative a] #

newtype Large a #

`Large x`: by default, QuickCheck generates `Int`s drawn from a small range. `Large Int` gives you values drawn from the entire range instead.

Constructors

Large |
Fields getLarge :: a

Instances

Functor Large # |
Methods fmap :: (a -> b) -> Large a -> Large b # (<$) :: a -> Large b -> Large a #
Enum a => Enum (Large a) # |
Methods succ :: Large a -> Large a # pred :: Large a -> Large a # toEnum :: Int -> Large a # fromEnum :: Large a -> Int # enumFrom :: Large a -> [Large a] # enumFromThen :: Large a -> Large a -> [Large a] # enumFromTo :: Large a -> Large a -> [Large a] # enumFromThenTo :: Large a -> Large a -> Large a -> [Large a] #
Eq a => Eq (Large a) # |
Methods (==) :: Large a -> Large a -> Bool # (/=) :: Large a -> Large a -> Bool #
Integral a => Integral (Large a) # |
Methods quot :: Large a -> Large a -> Large a # rem :: Large a -> Large a -> Large a # div :: Large a -> Large a -> Large a # mod :: Large a -> Large a -> Large a # quotRem :: Large a -> Large a -> (Large a, Large a) # divMod :: Large a -> Large a -> (Large a, Large a) # toInteger :: Large a -> Integer #
Num a => Num (Large a) # |
Methods (+) :: Large a -> Large a -> Large a # (-) :: Large a -> Large a -> Large a # (*) :: Large a -> Large a -> Large a # negate :: Large a -> Large a # abs :: Large a -> Large a # signum :: Large a -> Large a # fromInteger :: Integer -> Large a #
Ord a => Ord (Large a) # |
Methods compare :: Large a -> Large a -> Ordering # (<) :: Large a -> Large a -> Bool # (<=) :: Large a -> Large a -> Bool # (>) :: Large a -> Large a -> Bool # (>=) :: Large a -> Large a -> Bool # max :: Large a -> Large a -> Large a # min :: Large a -> Large a -> Large a #
Read a => Read (Large a) # |
Methods readsPrec :: Int -> ReadS (Large a) # readList :: ReadS [Large a] # readPrec :: ReadPrec (Large a) # readListPrec :: ReadPrec [Large a] #
Real a => Real (Large a) # |
Methods toRational :: Large a -> Rational #
Show a => Show (Large a) # |
Methods showsPrec :: Int -> Large a -> ShowS # show :: Large a -> String # showList :: [Large a] -> ShowS #
(Integral a, Bounded a) => Arbitrary (Large a) # |
Methods arbitrary :: Gen (Large a) # shrink :: Large a -> [Large a] #

newtype Small a #

`Small x`: generates values of `x` drawn from a small range. The opposite of `Large`.

Constructors

Small |
Fields getSmall :: a

Instances

Functor Small # |
Methods fmap :: (a -> b) -> Small a -> Small b # (<$) :: a -> Small b -> Small a #
Enum a => Enum (Small a) # |
Methods succ :: Small a -> Small a # pred :: Small a -> Small a # toEnum :: Int -> Small a # fromEnum :: Small a -> Int # enumFrom :: Small a -> [Small a] # enumFromThen :: Small a -> Small a -> [Small a] # enumFromTo :: Small a -> Small a -> [Small a] # enumFromThenTo :: Small a -> Small a -> Small a -> [Small a] #
Eq a => Eq (Small a) # |
Methods (==) :: Small a -> Small a -> Bool # (/=) :: Small a -> Small a -> Bool #
Integral a => Integral (Small a) # |
Methods quot :: Small a -> Small a -> Small a # rem :: Small a -> Small a -> Small a # div :: Small a -> Small a -> Small a # mod :: Small a -> Small a -> Small a # quotRem :: Small a -> Small a -> (Small a, Small a) # divMod :: Small a -> Small a -> (Small a, Small a) # toInteger :: Small a -> Integer #
Num a => Num (Small a) # |
Methods (+) :: Small a -> Small a -> Small a # (-) :: Small a -> Small a -> Small a # (*) :: Small a -> Small a -> Small a # negate :: Small a -> Small a # abs :: Small a -> Small a # signum :: Small a -> Small a # fromInteger :: Integer -> Small a #
Ord a => Ord (Small a) # |
Methods compare :: Small a -> Small a -> Ordering # (<) :: Small a -> Small a -> Bool # (<=) :: Small a -> Small a -> Bool # (>) :: Small a -> Small a -> Bool # (>=) :: Small a -> Small a -> Bool # max :: Small a -> Small a -> Small a # min :: Small a -> Small a -> Small a #
Read a => Read (Small a) # |
Methods readsPrec :: Int -> ReadS (Small a) # readList :: ReadS [Small a] # readPrec :: ReadPrec (Small a) # readListPrec :: ReadPrec [Small a] #
Real a => Real (Small a) # |
Methods toRational :: Small a -> Rational #
Show a => Show (Small a) # |
Methods showsPrec :: Int -> Small a -> ShowS # show :: Small a -> String # showList :: [Small a] -> ShowS #
Integral a => Arbitrary (Small a) # |
Methods arbitrary :: Gen (Small a) # shrink :: Small a -> [Small a] #

data Smart a #

`Smart _ x`: tries a different order when shrinking.

Constructors

Smart Int a |

Instances

Functor Smart # |
Methods fmap :: (a -> b) -> Smart a -> Smart b # (<$) :: a -> Smart b -> Smart a #
Show a => Show (Smart a) # |
Methods showsPrec :: Int -> Smart a -> ShowS # show :: Smart a -> String # showList :: [Smart a] -> ShowS #
Arbitrary a => Arbitrary (Smart a) # |
Methods arbitrary :: Gen (Smart a) # shrink :: Smart a -> [Smart a] #

newtype Shrink2 a #

`Shrink2 x`: allows 2 shrinking steps at the same time when shrinking x

Constructors

Shrink2 |
Fields getShrink2 :: a

Instances

Functor Shrink2 # |
Methods fmap :: (a -> b) -> Shrink2 a -> Shrink2 b # (<$) :: a -> Shrink2 b -> Shrink2 a #
Enum a => Enum (Shrink2 a) # |
Methods succ :: Shrink2 a -> Shrink2 a # pred :: Shrink2 a -> Shrink2 a # toEnum :: Int -> Shrink2 a # fromEnum :: Shrink2 a -> Int # enumFrom :: Shrink2 a -> [Shrink2 a] # enumFromThen :: Shrink2 a -> Shrink2 a -> [Shrink2 a] # enumFromTo :: Shrink2 a -> Shrink2 a -> [Shrink2 a] # enumFromThenTo :: Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a] #
Eq a => Eq (Shrink2 a) # |
Methods (==) :: Shrink2 a -> Shrink2 a -> Bool # (/=) :: Shrink2 a -> Shrink2 a -> Bool #
Integral a => Integral (Shrink2 a) # |
Methods quot :: Shrink2 a -> Shrink2 a -> Shrink2 a # rem :: Shrink2 a -> Shrink2 a -> Shrink2 a # div :: Shrink2 a -> Shrink2 a -> Shrink2 a # mod :: Shrink2 a -> Shrink2 a -> Shrink2 a # quotRem :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a) # divMod :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a) # toInteger :: Shrink2 a -> Integer #
Num a => Num (Shrink2 a) # |
Methods (+) :: Shrink2 a -> Shrink2 a -> Shrink2 a # (-) :: Shrink2 a -> Shrink2 a -> Shrink2 a # (*) :: Shrink2 a -> Shrink2 a -> Shrink2 a # negate :: Shrink2 a -> Shrink2 a # abs :: Shrink2 a -> Shrink2 a # signum :: Shrink2 a -> Shrink2 a # fromInteger :: Integer -> Shrink2 a #
Ord a => Ord (Shrink2 a) # |
Methods compare :: Shrink2 a -> Shrink2 a -> Ordering # (<) :: Shrink2 a -> Shrink2 a -> Bool # (<=) :: Shrink2 a -> Shrink2 a -> Bool # (>) :: Shrink2 a -> Shrink2 a -> Bool # (>=) :: Shrink2 a -> Shrink2 a -> Bool # max :: Shrink2 a -> Shrink2 a -> Shrink2 a # min :: Shrink2 a -> Shrink2 a -> Shrink2 a #
Read a => Read (Shrink2 a) # |
Methods readsPrec :: Int -> ReadS (Shrink2 a) # readList :: ReadS [Shrink2 a] # readPrec :: ReadPrec (Shrink2 a) # readListPrec :: ReadPrec [Shrink2 a] #
Real a => Real (Shrink2 a) # |
Methods toRational :: Shrink2 a -> Rational #
Show a => Show (Shrink2 a) # |
Methods showsPrec :: Int -> Shrink2 a -> ShowS # show :: Shrink2 a -> String # showList :: [Shrink2 a] -> ShowS #
Arbitrary a => Arbitrary (Shrink2 a) # |
Methods arbitrary :: Gen (Shrink2 a) # shrink :: Shrink2 a -> [Shrink2 a] #

data Shrinking s a #

`Shrinking _ x`: allows for maintaining a state during shrinking.

Constructors

Shrinking s a |

Instances

Functor (Shrinking s) # |
Methods fmap :: (a -> b) -> Shrinking s a -> Shrinking s b # (<$) :: a -> Shrinking s b -> Shrinking s a #
Show a => Show (Shrinking s a) # |
Methods showsPrec :: Int -> Shrinking s a -> ShowS # show :: Shrinking s a -> String # showList :: [Shrinking s a] -> ShowS #
(Arbitrary a, ShrinkState s a) => Arbitrary (Shrinking s a) # |
Methods arbitrary :: Gen (Shrinking s a) # shrink :: Shrinking s a -> [Shrinking s a] #

class ShrinkState s a where #

Minimal complete definition

shrinkInit, shrinkState

Methods

shrinkInit :: a -> s #

shrinkState :: a -> s -> [(a, s)] #

# Properties

data Property #

The type of properties.

Instances

Testable Property # |
Methods property :: Property -> Property #

class Testable prop where #

The class of things which can be tested, i.e. turned into a property.

Minimal complete definition

property

Methods

property :: prop -> Property #

Convert the thing to a property.

Instances

Testable Bool # |
Methods property :: Bool -> Property #
Testable Result # |
Methods property :: Result -> Property #
Testable Prop # |
Methods property :: Prop -> Property #
Testable Discard # |
Methods property :: Discard -> Property #
Testable Property # |
Methods property :: Property -> Property #
Testable prop => Testable (Gen prop) # |
Methods property :: Gen prop -> Property #
(Arbitrary a, Show a, Testable prop) => Testable (a -> prop) # |
Methods property :: (a -> prop) -> Property #

## Property combinators

forAll :: (Show a, Testable prop) => Gen a -> (a -> prop) -> Property #

Explicit universal quantification: uses an explicitly given test case generator.

forAllShrink :: (Show a, Testable prop) => Gen a -> (a -> [a]) -> (a -> prop) -> Property #

Like `forAll`, but tries to shrink the argument for failing test cases.

shrinking #

Arguments

:: Testable prop |
=> (a -> [a]) | `shrink`-like function.
-> a | The original argument
-> (a -> prop) |
-> Property |

Shrinks the argument to property if it fails. Shrinking is done automatically for most types. This is only needed when you want to override the default behavior.

(==>) :: Testable prop => Bool -> prop -> Property infixr 0 #

Implication for properties: The resulting property holds if the first argument is `False` (in which case the test case is discarded), or if the given property holds.

(===) :: (Eq a, Show a) => a -> a -> Property infix 4 #

Like `==`, but prints a counterexample when it fails.

ioProperty :: Testable prop => IO prop -> Property #

Do I/O inside a property. This can obviously lead to unrepeatable testcases, so use with care.

For more advanced monadic testing you may want to look at Test.QuickCheck.Monadic.

Note that if you use `ioProperty` on a property of type `IO Bool`, or more generally a property that does no quantification, the property will only be executed once. To test the property repeatedly you must use the `again` combinator.

### Controlling property execution

verbose :: Testable prop => prop -> Property #

Prints out the generated testcase every time the property is tested. Only variables quantified over inside the `verbose` are printed.

once :: Testable prop => prop -> Property #

Modifies a property so that it only will be tested once.

again :: Testable prop => prop -> Property #

Undoes the effect of `once`.

within :: Testable prop => Int -> prop -> Property #

Considers a property failed if it does not complete within the given number of microseconds.

noShrinking :: Testable prop => prop -> Property #

Disables shrinking for a property altogether.

### Conjunction and disjunction

(.&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #

Nondeterministic choice: `p1` `.&.` `p2` picks randomly one of `p1` and `p2` to test. If you test the property 100 times it makes 100 random choices.

(.&&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #

Conjunction: `p1` `.&&.` `p2` passes if both `p1` and `p2` pass.

conjoin :: Testable prop => [prop] -> Property #

Take the conjunction of several properties.

(.||.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #

Disjunction: `p1` `.||.` `p2` passes unless `p1` and `p2` simultaneously fail.

disjoin :: Testable prop => [prop] -> Property #

Take the disjunction of several properties.

### What to do on failure

counterexample :: Testable prop => String -> prop -> Property #

Adds the given string to the counterexample.

printTestCase :: Testable prop => String -> prop -> Property #

Deprecated: Use counterexample instead

Adds the given string to the counterexample.

whenFail :: Testable prop => IO () -> prop -> Property #

Performs an `IO` action after the last failure of a property.

whenFail' :: Testable prop => IO () -> prop -> Property #

Performs an `IO` action every time a property fails. Thus, if shrinking is done, this can be used to keep track of the failures along the way.

expectFailure :: Testable prop => prop -> Property #

Indicates that a property is supposed to fail. QuickCheck will report an error if it does not fail.

### Analysing test distribution

label :: Testable prop => String -> prop -> Property #

Attaches a label to a property. This is used for reporting test case distribution.

collect :: (Show a, Testable prop) => a -> prop -> Property #

Labels a property with a value:

    collect x = label (show x)

classify #

Arguments

:: Testable prop |
=> Bool | `True` if the test case should be labelled.
-> String | Label.
-> prop |
-> Property |

Conditionally labels test case.

cover #

Arguments

:: Testable prop |
=> Bool | `True` if the test case belongs to the class.
-> Int | The required percentage (0-100) of test cases.
-> String | Label for the test case class.
-> prop |
-> Property |

Checks that at least the given proportion of successful test cases belong to the given class. Discarded tests (i.e. ones with a false precondition) do not affect coverage.

### Miscellaneous

data Discard #

If a property returns `Discard`, the current test case is discarded, the same as if a precondition was false.

Constructors

Discard |

Instances

Testable Discard # |
Methods property :: Discard -> Property #

discard :: a #

A special exception that makes QuickCheck discard the test case. Normally you should use `==>`, but if for some reason this isn't possible (e.g. you are deep inside a generator), use `discard` instead.

mapSize :: Testable prop => (Int -> Int) -> prop -> Property #

Changes the maximum test case size for a property.