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.

// 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 setA: LawSet = LawSet(setA)(
'another feature under test',
Law('law₁', '∀n ∈ ℕ: n - n = 0', tinyPositive)(x => x - x === 0),
)
  • Parameters

    • Rest...sets: LawSet[]

      Requirements for the new LawSet.

    Returns ((name?: string, ...laws: Law<any>[]) => LawSet)

      • (name?, ...laws): LawSet
      • Parameters

        • name: string = ''

          Test suite name.

        • Rest...laws: Law<any>[]

          List of Laws that must pass for this LawSet to pass.

        Returns LawSet