A toolkit for writing property-based tests, which take the form of Claims. A
Claim is made using the provided domain-specific language (DSL). A single
Claim can be written in one of these ways:
For example,
claim_multiplication_identity =
claim
"Multiplying by one does not change a number"
`that`
(\n -> n * 1)
`is`
identity
`for`
intSee the README for more information.
Warning: The DSL follows a very strict format. Deviating from this format will yield potentially unintelligible type errors. The following functions have horrendous type signatures and you are better off ignoring them.
Group a list of claims into a suite. This is very useful in order to group similar claims together.
suite nameOfSuite listOfClaimsQuickly check a claim.
This function is very useful when checking claims in local development.
quickCheck will perform 100 checks and use Random.initialSeed 1 as the
random seed.
Check a claim and produce evidence.
To check a claim, you need to provide the number of checks to perform, and a random seed. You can set up a CI server to run through a large number of checks with a randomized seed.
aggressiveCheck : Claim -> Evidence
aggressiveCheck =
check 2000 (Random.initialSeed 0xFFFF)A Claim is an object that makes a claim of truth about a system. A claim is either a function which yields evidence regarding the claim or a list of such claims.
The results of checking a claim are given back in the types defined here. You
can examine them yourself, or see Check.Test to convert them into tests to use
with elm-check's runners.
Evidence is the output from checking a claim or multiple claims.
UnitEvidence is the concrete type returned by checking a single claim. A UnitEvidence can easily be converted to an assertion or can be considered as the result of an assertion.
SuccessOptions is the concrete type returned in case there is no evidence found disproving a Claim.
SuccessOptions contains:
name of the claimseed used in order to reproduce the check.FailureOptions is the concrete type returned in case evidence was found disproving a Claim.
FailureOptions contains:
name of the claimcounterExample which serves as evidence that the claim is falseexpected to be returned by the claimactual value returned by the claimseed used in order to reproduce the resultscounterExample, actual, and expected values found prior
to performing the shrinking operations.