Entity / foldkit-entity/conformance

Conformance

namespace · packages/entity/src/conformance/operator.ts:422

const Conformance = { memory, laws, lawsBy, operator }

In the guides

Members

Conformance.memory

function · packages/entity/src/conformance/operator.ts:424

memory(operators: MemoryOperators): Runner

A runner of calls through a memory table: Conformance.operator's for the in-memory interpreter.

Conformance.laws

function · packages/entity/src/conformance/operator.ts:436

laws<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(
  op: Operator<In, Out>,
  operators: MemoryOperators,
  options?: {
    readonly implementation?: string | undefined
    readonly cases?: number | undefined
    readonly seed?: number | undefined
  },
): LawsVerdict

Tests every law op declares against operators' implementation of it, up to cases tuples a law (200 by default), chosen by seed (0); a law of both sides checks each tuple from each. Holds with a Tested record a law, which Operators.withEvidence keeps; or the first case a law fails, with both sides.

Conformance.lawsBy

function · packages/entity/src/conformance/operator.ts:469

lawsBy<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(
  op: Operator<In, Out>,
  run: Runner,
  options: {
    readonly implementation: string
    readonly cases?: number | undefined
    readonly seed?: number | undefined
  },
): Promise<LawsVerdict>

As laws, each call run by run instead of a memory table: an SQL implementation selected from a database, say, whose evidence a binding's SQL table records. A throw is a refusal.

Conformance.operator

function · packages/entity/src/conformance/operator.ts:511

operator<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(
  op: Operator<In, Out>,
  options: {
    readonly implementations: Readonly<Record<string, Runner>>
    readonly cases?: ReadonlyArray<ReadonlyArray<unknown>> | undefined
    readonly limit?: number | undefined
    readonly seed?: number | undefined
    readonly expansionTable?: MemoryOperators | undefined
  },
): Promise<OperatorReport>

Runs one set of calls of op through every implementation and compares what each answered or refused. The calls are cases (argument tuples, as stored), or generated: each argument a sample of its kind, null where its schema admits one, and text holding NUL, under binary and asciiFold where the operator compares text, up to limit (300) chosen by seed (0). A defined operator's expansion is run beside the others, as expansion, by expansionTable (the kernel's when not given).