elm-explorations / test / Test.Distribution

Distribution


type alias ExpectedDistribution =
Internal.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 : Basics.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.


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

A result of a distribution check.

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

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

Prettyprints the record inside DistributionReport into a table with histograms.