elm-explorations/test/2.2.0

NOTE: the latest version is 2.2.1

Test.Distribution

Distribution

ExpectedDistribution

Your input distribution requirement for the fuzzer used in a test.

For example, "this test shouldn't ever receive strings of length < 3 as an input" or "at least 30% of the test input trees should be balanced".

atLeast : Float -> ExpectedDistribution

A requirement that a given value class should happen at least N% of the time in a given test.

The example below says that at least 30% of the fuzz test inputs should be multiples of 3.

fuzzWith
    { runs = 10000
    , distribution =
        expectDistribution
            [ ( atLeast 30, "multiple of 3", \n -> (n |> modBy 3) == 0 )
            ]
    }
zero : ExpectedDistribution

A requirement that a given value class should never happen in a given test.

moreThanZero : ExpectedDistribution

A requirement that a given value class should happen at least once in a given test.

= NoDistribution
| DistributionToReport
{ distributionCount : Dict (List String) Int
, runsElapsed : Int
}
| DistributionCheckSucceeded
{ distributionCount : Dict (List String) Int
, runsElapsed : Int
}
| DistributionCheckFailed
{ distributionCount : Dict (List String) Int
, runsElapsed : Int
, badLabel : String
, badLabelPercentage : Float
, expectedDistribution : String
}

A result of a distribution check.

Get it from your Expectation with Test.Runner.getDistributionReport.

{ a
| runsElapsed : Int
, distributionCount : Dict (List String) Int
}
-> String

Prettyprints the record inside DistributionReport into a table with histograms.