Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Test case generation.
- newtype Gen a = MkGen {}
- variant :: Integral n => n -> Gen a -> Gen a
- sized :: (Int -> Gen a) -> Gen a
- resize :: Int -> Gen a -> Gen a
- scale :: (Int -> Int) -> Gen a -> Gen a
- choose :: Random a => (a, a) -> Gen a
- chooseAny :: Random a => Gen a
- generate :: Gen a -> IO a
- sample' :: Gen a -> IO [a]
- sample :: Show a => Gen a -> IO ()
- suchThat :: Gen a -> (a -> Bool) -> Gen a
- suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
- oneof :: [Gen a] -> Gen a
- frequency :: [(Int, Gen a)] -> Gen a
- elements :: [a] -> Gen a
- sublistOf :: [a] -> Gen [a]
- shuffle :: [a] -> Gen [a]
- growingElements :: [a] -> Gen a
- listOf :: Gen a -> Gen [a]
- listOf1 :: Gen a -> Gen [a]
- vectorOf :: Int -> Gen a -> Gen [a]
- infiniteListOf :: Gen a -> Gen [a]
Generator type
A generator for values of type a
.
Primitive generator combinators
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.
Run a generator. The size passed to the generator is always 30;
if you want another size then you should explicitly use resize
.
Common generator combinators
suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a) #
Tries to generate a value that satisfies a predicate.
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.
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.
Generates a list of random length. The maximum length depends on the size parameter.
Generates a non-empty list of random length. The maximum length depends on the size parameter.
infiniteListOf :: Gen a -> Gen [a] #
Generates an infinite list.