The Test.checkN
functions work much like the Test.fuzzN
functions from elm-test
, except
you pass Generator
values instead of Fuzzer
values and the description is passed first (I
personally think it reads better that way).
Internally, the given generators will be:
Fuzzer
using Fuzz.fromGenerator
Test.fuzz
check : String -> Random.Generator a -> (a -> Expectation) -> Test
check2 : String -> Random.Generator a -> Random.Generator b -> (a -> b -> Expectation) -> Test
check3 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> (a -> b -> c -> Expectation) -> Test
check4 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> Random.Generator d -> (a -> b -> c -> d -> Expectation) -> Test
check5 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> Random.Generator d -> Random.Generator e -> (a -> b -> c -> d -> e -> Expectation) -> Test
check6 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> Random.Generator d -> Random.Generator e -> Random.Generator f -> (a -> b -> c -> d -> e -> f -> Expectation) -> Test
check7 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> Random.Generator d -> Random.Generator e -> Random.Generator f -> Random.Generator g -> (a -> b -> c -> d -> e -> f -> g -> Expectation) -> Test
check8 : String -> Random.Generator a -> Random.Generator b -> Random.Generator c -> Random.Generator d -> Random.Generator e -> Random.Generator f -> Random.Generator g -> Random.Generator h -> (a -> b -> c -> d -> e -> f -> g -> h -> Expectation) -> Test
checkExpectation : String -> Random.Generator Expectation -> Test
If you need to write tests with more than 8 inputs or otherwise need more flexibility, you can
use this function. Instead of passing value generators and an expectation function separately, you
use whatever functionality you want to build up a Generator Expectation
and then test that.
For example,
Test.Random.check2 "My test"
firstGenerator
secondGenerator
Expect.equal
could be written as
Test.Random.checkExpectation "My test" <|
Random.map2 Expect.equal
firstGenerator
secondGenerator
where existing Random
functionality (in this case Random.map2
) is used to convert a couple of
value generators into an Expectation
generator.