Decorum.Prng (decorum v0.1.0)
Prng
(pseudo random number generator) is a wrapper around the :rand
module.
It has 2 states:
Random Uses
:rand
to generate random numbers and stores each one in history.Hardcoded Used to replay a previously recorded (or simplified) history.
We represent random values using 32-bit non-negative integers because they are easier to work with when shrinking the history.
Summary
Functions
Takes a Prng
struct and returns a tuple with the next random value
and an updated Prng
struct.
Types
@opaque t()
Functions
next!(prng)
@spec next!(prng :: t()) :: {non_neg_integer(), t()}
Takes a Prng
struct and returns a tuple with the next random value
and an updated Prng
struct.
When in Random
state, next!/1
is not expected to fail.
When in Hardcoded
state, next!/1
could raise a Decorum.EmptyHistoryError
.
Generators will call next!/1
to get a value to use when
generating test values. They should also return the updated Prng
struct.