This is a library of Producers you can use to supply values to your tests.
You can typically pick out which ones you need according to their types.
A Producer a knows how to create values of type a. It can create them
randomly, and it can shrink them to more minimal values. Producers can be
filtered and mapped over.
A producer for int values.
A producer for int values within between a given minimum and maximum value, inclusive. Shrunken values will also be within the range.
A producer for float values. NaN and ±Infinity will not be produced.
A producer for float values within between a given minimum and maximum value, inclusive. Shrunken values will also be within the range.
A producer for percentage values. Generates random floats between 0.0 and
1.0.
A producer for string values. Generates random printable ascii strings whose length is between 0 and 10.
Given a producer of a type, create a producer of a maybe for that type.
Given producers for an error type and a success type, createa a producer for a result.
Given a producer of a type, create a producer of a list of that type. Generates random lists of values of length between 0 and 10.
Given a producer of a type, create a producer of an array of that type. Generates random arrays of values of length between 0 and 10.
If your expected and actual functions need more than one input, pass them in as a tuple.
Turn a tuple of producers into a producer of tuples.
Turn a 3-tuple of producers into a producer of 3-tuples.
Turn a 4-tuple of producers into a producer of 4-tuples.
Turn a 5-tuple of producers into a producer of 5-tuples.
An Producer type is a
Random
Generator paired with a shrinking strategy, or Shrinker. Shrinkers are defined
in
elm-shrink.
Filter the values from a Producer. The resulting Producer will only generate random test values or shrunken values that satisfy the predicate. The predicate must be satisfiable.
Convert the output of one producer to another type. This is useful if you're testing a function that expects a large model record, but you only need to randomize a few fields. You might do this several different ways for a single model, so you generate and shrink only the fields relevant to each test.
type alias Person =
{ first : String, last : String, age : String }
spy : Producer Person
spy = map (\age -> Person "James" "Bond" age) .age (rangeInt 0 120)In order for shrinking to work, you need to pass an inverse function of the function being mapped.
Map a function over an producer. This works exactly like convert,
except it does not require an invderse function, and consequently does no
shrinking.
A producer for the unit value. Unit is a type with only one value, commonly used as a placeholder.
A producer for order values.
A producer for char values. Generates random ascii chars disregarding the control characters.
A producer for uppercase char values.
A producer for lowercase char values.
A producer for ASCII char values.
A producer for unicode char values.
Given a producer of a return type, create a producer of functions that return that type. Does not perform any shrinking.
A producer for bool values.