QuickCheck-2.7.2: Automatic testing of Haskell programs

Safe HaskellNone

Test.QuickCheck.Gen

Contents

Description

Test case generation.

Synopsis

Generator type

newtype Gen a Source

A generator for values of type a.

Constructors

MkGen 

Fields

unGen :: QCGen -> Int -> a

Run the generator on a particular seed. If you just want to get a random value out, consider using generate.

Instances

Primitive generator combinators

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

Modifies a generator using an integer seed.

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

Used to construct generators that depend on the size parameter.

resize :: Int -> Gen a -> Gen aSource

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

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

Generates a random element in the given inclusive range.

generate :: Gen a -> IO aSource

Run a generator.

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

Generates some example values.

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

Generates some example values and prints them to stdout.

Common generator combinators

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

Generates a value that satisfies a predicate.

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

Tries to generate a value that satisfies a predicate.

oneof :: [Gen a] -> Gen aSource

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

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

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

elements :: [a] -> Gen aSource

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

growingElements :: [a] -> Gen aSource

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.

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

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

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

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

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

Generates a list of the given length.

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

Generates an infinite list.