Argument type of predicate. For example, if the law
predicate signature is Predicate<[a: number, b: string]>
, then T
would be [a: number, b: string]
.
Law name, shown as test label.
String note to be shown on failure or in verbose mode.
A tuple of arbitraries, one per predicate argument.
Law predicate. Its argument type is encoded in Ts
.
Optional
parameters: ParameterOverridesfast-check
runtime parameters.
import {Law, checkLaw, tinyPositive} from 'effect-ts-laws'
import {Option as OP} from 'effect'
export const law: Law<[number, number]> = Law(
'sum of positives ≥ both', // • law name
'∀a,b in N, sum=a+b: sum≥a ∧ sum≥b', // • law note
tinyPositive, // • list of
tinyPositive, // arbitraries that
)( // are required for...
(x, y) => x + y >= x && x + y >= y, // • the law predicate
{numRuns: 10_000}, // • optional runtime config
)
assert.equal(law.name, 'sum of positives ≥ both')
assert.deepStrictEqual(checkLaw(law), OP.none())
Build a law from a name, a predicate, an optional note, an arbitrary for the predicate arguments, and optional
fast-check
runtime parameters. The runtime parameters are documented here.