Closed Hexirp closed 3 years ago
I suggest:
type Question
= Name String
| Age Int
question =
let
generator =
uniform True [False]
|> Random.andThen
(\b ->
if b then
Random.map Name genName
else
Random.map Age (Random.int 0 120)
)
shrinker question =
case question of
Name n ->
Shrink.string n |> Shrink.map Name
Age i ->
Shrink.int i |> Shrink.map Age
in
Fuzz.custom generator shrinker
Good catch! Wanna make a PR?
The description of
custom
has a mistake on its code snippet .https://github.com/elm-explorations/test/blob/74076ea9869d1ac70c8c7f674c87946784911506/src/Fuzz.elm#L93-L118
It uses
Random.bool
, however Random of elm/random 1.0.0 doesn't containbool
.