A claim is a function that maps a subject to a verdict.
The result of applying a claim to a subject.
A claim about a subject will either be accepted or rejected.
Claim that the subject is equal to the provided value.
The first argument to this function converts a value of some type to a string, which
is used to produce readable messages if the claim is rejected. Instead of providing
this string-generating function each time, I suggest adding a helper function that just uses the
Debug.toString function like so:
equals : a -> Claim a
equals =
Spec.Claim.isEqual Debug.toStringThen just use your equals function whenever you need to claim that a subject is equal to some value.
Claim that the subject is True
Claim that the subject is False
Claim that the subject contains the given string the given number of times.
For example,
"some funny string"
|> isStringContaining 2 "fun"would be rejected, since it contains fun only once.
Claim that the subject is a list where the following claims are satisfied:
For example:
[ 1, 2, 3 ]
|> Spec.Claim.isListWhere
[ Spec.Claim.isEqual Debug.toString 1
, Spec.Claim.isEqual Debug.toString 27
, Spec.Claim.isEqual Debug.toString 3
]would result in a rejected claim, since 2 is not equal to 27.
Claim that the subject is a list such that:
Claim that the subject is a list with the given length.
Claim that the subject is the Just case of the Maybe type.
Claim that the subject is the Just case of the Maybe type and that
the associated value satisfies the given claim.
For example,
Just "apple"
|> isSomethingWhere (isStringContaining 1 "cheese")would be rejected.
Claim that the subject is the Nothing case of the Maybe type.
Combine multiple claims into one.
If any of the claims is rejected, then the combined claim is rejected.
Claim that a value derived from the subject satisfies the given claim.
For example, the following claim:
{ x = 27, y = 31 }
|> specifyThat .y (isEqual Debug.toString 31)would be accepted.
Modify the report associated with a rejected verdict; otherwise, do nothing.
Represents a function from a subject to a verdict.