nri-prelude-0.1.0.0: A Prelude inspired by the Elm programming language

Safe HaskellNone
LanguageHaskell2010

Fuzz

Contents

Description

This is a library of fuzzers you can use to supply values to your fuzz tests. You can typically pick out which ones you need according to their types. A Fuzzer a knows how to create values of type a in two different ways. It can create them randomly, so that your test's expectations are run against many values. Fuzzers will often generate edge cases likely to find bugs. If the fuzzer can make your test fail, it also knows how to "shrink" that failing input into more minimal examples, some of which might also cause the tests to fail. In this way, fuzzers can usually find the smallest or simplest input that reproduces a bug.

Synopsis

Common Fuzzers

int :: Fuzzer Int Source #

A fuzzer for int values. It will never produce NaN, Infinity, or -Infinity. It's possible for this fuzzer to generate any 32-bit integer, signed or unsigned, but it favors numbers between -50 and 50 and especially zero.

intRange :: Int -> Int -> Fuzzer Int Source #

A fuzzer for int values between a given minimum and maximum value, inclusive. Shrunken values will also be within the range. Remember that Random.maxInt is the maximum possible int value, so you can do intRange x Random.maxInt to get all the ints x or bigger.

list :: Fuzzer a -> Fuzzer (List a) Source #

Given a fuzzer of a type, create a fuzzer of a list of that type. Generates random lists of varying length, favoring shorter lists.

Working with Fuzzers