Requirements for the new LawSet
.
Test suite name.
List of Laws that must pass for this LawSet
to pass.
import {checkLaws, Law, LawSet, tinyPositive} from 'effect-ts-laws'
// A pair of laws with no law sets.
const setA: LawSet = LawSet()(
'some feature under test',
Law('law₁', '∀n ∈ ℕ: n = n', tinyPositive)(x => x === x),
Law('law₂', '∀n ∈ ℕ: n ≤ n', tinyPositive)(x => x <= x),
)
// Another that will run “setA” _before_ its own laws
const setB: LawSet = LawSet(setA)(
'another feature under test',
Law('law₁', '∀n ∈ ℕ: n - n = 0', tinyPositive)(x => x - x === 0),
)
// Will check “setA” as a prerequisite
assert.deepStrictEqual(checkLaws(setB), [])
Assemble a set of laws for some unit under test. You can check them using the functions checkLaw and checkLaws. They can be tested in a vitest test suite using the testLaw and testLaw functions.