@systemfsoftware/vitest 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/failure.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
 
2
- import { a as Values, i as PropertySubject, l as Breach, n as Gens, o as engine_d_exports, r as PropertySpec } from "./engine-CMvYG5V0.js";
2
+ import { A as VacuousProperty, C as witnessOf, M as Breach, S as throwFailureRecord, _ as ReplayValue, a as PropertySubject, b as summaryOf, d as ProvidedCheckDefaults, g as JsonValue, h as FailureRecordInput, i as PropertySpec, j as Witness, m as FailureRecord, n as Gens, o as Values, p as AttributeValue, r as PropApi, s as engine_d_exports, v as TestIdentity, x as testIdentityOf, y as renderFailureRecord } from "./engine-D7Q6-BxD.js";
3
3
  import { i as Checks, t as Asserted } from "./checks-DiuzHhQM.js";
4
- import * as Cause from "effect/Cause";
5
4
  import * as Effect$1 from "effect/Effect";
6
5
  import * as Tracer from "effect/Tracer";
7
6
  import { Option, Schema } from "effect";
@@ -16,116 +15,6 @@ export declare const withRaisingFrame: {
16
15
  (frame: string | undefined): <A extends Error>(error: A) => A;
17
16
  };
18
17
  //#endregion
19
- //#region src/internal/failure-record.d.ts
20
- /** A value the renderer narrows rather than assumes. */
21
- type Opaque<A = unknown> = A;
22
- /**
23
- * A value a recorded span attribute or a replay path carries. Structured values stay structured on the span
24
- * (KTD2); the renderer decides the text.
25
- *
26
- * @internal
27
- */
28
- type AttributeValue = string | number | boolean | null | ReadonlyArray<AttributeValue> | {
29
- readonly [key: string]: AttributeValue;
30
- };
31
- /**
32
- * The test a failure happened in, as Vitest knows it. `file` is the path the rerun command names, so a caller
33
- * that holds an absolute path derives the repo-relative one before handing it over.
34
- *
35
- * @internal
36
- */
37
- interface TestIdentity {
38
- /**
39
- * The npm package the test file belongs to, e.g. `@systemfsoftware/effect-readiness`. Empty when the run
40
- * provided no name: the rerun command then drops its `pnpm --filter` prefix and runs from the package
41
- * directory, which is not a breach (R6).
42
- */
43
- readonly package: string;
44
- /** The test file, as the rerun command writes it. */
45
- readonly file: string;
46
- /** The scenario name the rerun command filters on with `-t`. */
47
- readonly name: string;
48
- }
49
- /**
50
- * The value a generator chose a run by: the kernel's seed and decision path, or a property counterexample's
51
- * seed and path. A path without a seed is a replay value offered for a baseline run, which R6 refuses (KTD5).
52
- *
53
- * @internal
54
- */
55
- interface ReplayValue {
56
- /** The generator's seed, or `undefined` when only a path was recorded. */
57
- readonly seed: number | undefined;
58
- /** The decisions the generator chose, in order; a decision is the index the scheduler picked (KTD5). */
59
- readonly path: ReadonlyArray<number>;
60
- }
61
- /**
62
- * A contract rule a rendered record breaks; the runner refuses such a record (R10, KTD7).
63
- *
64
- * @internal
65
- */
66
- /**
67
- * What a rendered failure gives Vitest: the tag the error carries, the record text, and the rules it breaks.
68
- *
69
- * @internal
70
- */
71
- interface FailureRecord {
72
- /** The headline's failure tag, e.g. `StepError`; the runner sets it as the thrown error's `name`. */
73
- readonly name: string;
74
- /** The text Vitest prints as the failure's message. */
75
- readonly record: string;
76
- /** The contract rules the record breaks: `R1` empty headline, `R2` no location, `R6` replay or rerun. */
77
- readonly breaches: ReadonlyArray<Breach>;
78
- }
79
- /**
80
- * Everything one failure is rendered from: the failure, its run's spans, the test and the replay value.
81
- *
82
- * @internal
83
- */
84
- interface FailureRecordInput<E = never> {
85
- /** The failure itself: a `Cause`, or the value a program threw or failed with. */
86
- readonly failure: Cause.Cause<E> | E;
87
- /** Every span the failing run recorded, in creation order. */
88
- readonly spans: ReadonlyArray<Tracer.NativeSpan>;
89
- /** The test the run belonged to. */
90
- readonly identity: TestIdentity;
91
- /** The generator that chose this run, or `undefined` on a run no generator chose. */
92
- readonly replay: ReplayValue | undefined;
93
- /**
94
- * The seed the kernel's scheduler chose. The kernel knows its own scheduler, so it hands the note over rather
95
- * than the renderer guessing it; a run no scheduler chose renders no note (KTD5).
96
- */
97
- readonly schedule?: {
98
- readonly seed: number;
99
- } | undefined;
100
- /**
101
- * The workspace root the rendered paths are relativized against, provided by the shared config the same way the
102
- * package name is. Omitted, paths print absolute.
103
- */
104
- readonly root?: string | undefined;
105
- }
106
- /** @internal */
107
- export declare const summaryOf: (value: Opaque) => string;
108
- /**
109
- * Renders the record Vitest prints for one spec failure, and the contract rules it breaks.
110
- *
111
- * Never throws: a `Cause` renders layer by layer, a thrown `Error` renders as one layer, and any other value
112
- * renders as itself. The first location the record names is the raising frame — the first stack frame outside
113
- * `node_modules` and outside the spec libraries' own `src/` and `dist/` — and when no layer has one, the
114
- * innermost failed span's site stands in, or the innermost unfinished cell's decide site for a deadlock (KTD6).
115
- *
116
- * @internal
117
- */
118
- export declare const renderFailureRecord: <E>(input: FailureRecordInput<E>) => FailureRecord;
119
- /** @internal */
120
- export declare const throwFailureRecord: <E>(input: FailureRecordInput<E>) => never;
121
- interface TaskLike {
122
- readonly name?: string | undefined;
123
- readonly fullName?: string | undefined;
124
- readonly fullTestName?: string | undefined;
125
- }
126
- /** @internal */
127
- export declare const testIdentityOf: (task?: TaskLike | null) => TestIdentity;
128
- //#endregion
129
18
  //#region src/internal/provided.schema.d.ts
130
19
  /**
131
20
  * The workspace root every rendered path is relativized against.
@@ -150,6 +39,10 @@ interface RecordedProperty<G extends Gens, S extends PropertySubject, N extends
150
39
  readonly name: string;
151
40
  readonly spec: PropertySpec<G, S, N>;
152
41
  readonly holds: (subject: S, values: Values<G>) => boolean;
42
+ /** The provided budget the run supplies in place of the configured default, e.g. a derandomizing `seed`. */
43
+ readonly budget?: ProvidedCheckDefaults | undefined;
44
+ /** The path of the test file whose seed store to read and write; absent, the run keeps no store. */
45
+ readonly store?: string | undefined;
153
46
  }
154
47
  /**
155
48
  * Runs one program as the runner runs a lane, with a fresh ledger and its own recorder, and resolves with the
@@ -158,6 +51,11 @@ interface RecordedProperty<G extends Gens, S extends PropertySubject, N extends
158
51
  * @internal
159
52
  */
160
53
  export declare const recordOfRun: <A, E>(program: RecordedRun<A, E>) => Promise<FailureRecord | undefined>;
54
+ /** @internal */
55
+ interface RecordedFile {
56
+ readonly records: ReadonlyArray<FailureRecord | undefined>;
57
+ readonly vacuous: VacuousProperty | undefined;
58
+ }
161
59
  /**
162
60
  * Runs one property the way the runner runs `it.prop`, with a fresh ledger and its own recorder, and resolves with
163
61
  * the record its falsification rendered — or `undefined` when it held.
@@ -165,6 +63,21 @@ export declare const recordOfRun: <A, E>(program: RecordedRun<A, E>) => Promise<
165
63
  * @internal
166
64
  */
167
65
  export declare const recordOfProperty: <const G extends Gens, S extends PropertySubject, N extends number>(input: RecordedProperty<G, S, N>) => Promise<FailureRecord | undefined>;
66
+ interface RecordedFileOptions {
67
+ readonly budget?: ProvidedCheckDefaults | undefined;
68
+ readonly store?: string | undefined;
69
+ }
70
+ /**
71
+ * Runs every property and law a file registers, in registration order, then finalises the file's one ledger:
72
+ * resolves with each property's rendered failure and the file's single vacuous verdict, or `undefined` when the
73
+ * file holds. The name a property is recorded under is the name it was registered with.
74
+ *
75
+ * @internal
76
+ */
77
+ export declare const recordOfFile: {
78
+ (register: (api: PropApi<never>) => void, options?: RecordedFileOptions): Promise<RecordedFile>;
79
+ (options?: RecordedFileOptions): (register: (api: PropApi<never>) => void) => Promise<RecordedFile>;
80
+ };
168
81
  //#endregion
169
82
  //#region src/internal/span-recorder.d.ts
170
83
  /** @internal */
@@ -191,8 +104,8 @@ export type Replay = typeof Replay.Type;
191
104
  */
192
105
  export declare const replayOfText: (text: string) => Replay;
193
106
  /**
194
- * The replay codec: `Schema.String` in, a replay out. A text that names no seed and path fails the decode, and
195
- * every replay encodes back to the text it was read from.
107
+ * The kernel's replay codec: `Schema.String` in, a replay out. A text that names no seed and path fails the decode,
108
+ * and every replay encodes back to the text it was read from.
196
109
  *
197
110
  * @since 4.0.0
198
111
  */
@@ -201,4 +114,4 @@ export declare const ReplayFromText: Schema.decodeTo<Schema.Struct<{
201
114
  readonly path: Schema.$Array<Schema.brand<Schema.Int, "ReplayStep">>;
202
115
  }>, Schema.String, never, never>;
203
116
  //#endregion
204
- export { type AttributeValue, type Breach, type FailureRecord, type FailureRecordInput, type RecordedProperty, type RecordedRun, type ReplayValue, type SpanRecorder, type TestIdentity, providedRoot as providedWorkspaceRoot };
117
+ export { type AttributeValue, type Breach, type FailureRecord, type FailureRecordInput, type JsonValue, type RecordedFile, type RecordedProperty, type RecordedRun, type ReplayValue, type SpanRecorder, type TestIdentity, type Witness, providedRoot as providedWorkspaceRoot, renderFailureRecord, summaryOf, testIdentityOf, throwFailureRecord, witnessOf };
package/dist/failure.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- import { _ as ReplayFromText, c as summaryOf, d as providedRoot, g as Replay, l as testIdentityOf, n as recordOfRun, r as createSpanRecorder, s as renderFailureRecord, t as recordOfProperty, u as throwFailureRecord, v as replayOfText } from "./failure-D8mPXwf4.mjs";
2
+ import { E as replayOfText, T as ReplayFromText, _ as testIdentityOf, b as providedRoot, g as summaryOf, h as renderFailureRecord, i as createSpanRecorder, n as recordOfProperty, r as recordOfRun, t as recordOfFile, v as throwFailureRecord, w as Replay, y as witnessOf } from "./failure-nvq5TwWX.mjs";
3
3
  import { c as callFrameOutside, l as callSite, p as withRaisingFrame } from "./test-context-D_-acRSc.mjs";
4
- export { Replay, ReplayFromText, callFrameOutside, callSite, createSpanRecorder, providedRoot as providedWorkspaceRoot, recordOfProperty, recordOfRun, renderFailureRecord, replayOfText, summaryOf, testIdentityOf, throwFailureRecord, withRaisingFrame };
4
+ export { Replay, ReplayFromText, callFrameOutside, callSite, createSpanRecorder, providedRoot as providedWorkspaceRoot, recordOfFile, recordOfProperty, recordOfRun, renderFailureRecord, replayOfText, summaryOf, testIdentityOf, throwFailureRecord, withRaisingFrame, witnessOf };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./compat.d.ts" />
2
- import { a as Values$1, c as kinds_d_exports, i as PropertySubject$1, n as Gens$1, o as engine_d_exports, r as PropertySpec$1, s as LawApi, t as ArbitraryInput, u as __exportAll } from "./engine-CMvYG5V0.js";
2
+ import { A as VacuousProperty, D as ReplayUnreadable, E as PropertyRefuted, N as __exportAll, O as SeedStoreUnreadable, T as NonBooleanVerdict, a as PropertySubject$1, c as LawApi, d as ProvidedCheckDefaults, f as checkDefaultsKey, i as PropertySpec$1, k as SelfModelLaw, l as kinds_d_exports, n as Gens$1, o as Values$1, s as engine_d_exports, t as ArbitraryInput, u as PropertyBudget, w as CoverageBelowMinimum } from "./engine-D7Q6-BxD.js";
3
3
  import { a as Expect, c as NoCheckRefusal, d as RefuseSyncBody, f as ScopedLaneRefusal, i as Checks, l as RefuseAsyncBody, m as UnprovidedRefusal, o as EffectLaneRefusal, p as ScopedLiveLaneRefusal, r as Check, s as HookRefusal, t as Asserted, u as RefuseEffectBody } from "./checks-DiuzHhQM.js";
4
4
  import * as V from "vitest";
5
5
  import { afterAll, assertType, beforeAll, expectTypeOf, inject, onTestFailed, onTestFinished, recordArtifact, vi, vitest } from "vitest";
@@ -9,15 +9,8 @@ import * as Layer from "effect/Layer";
9
9
  import * as Scope from "effect/Scope";
10
10
  import * as TestConsole from "effect/testing/TestConsole";
11
11
  import * as Context from "effect/Context";
12
- import * as Arbitrary from "effect/Arbitrary";
13
12
  import * as Clock from "effect/Clock";
14
13
  import * as Scheduler from "effect/Scheduler";
15
- //#region src/internal/property/defaults.d.ts
16
- /** @internal The `test.provide` key the shared config fills with this run's tier's check options. */
17
- declare const checkDefaultsKey = "@systemfsoftware/vitest:property-check";
18
- /** @internal The check options a run supplies as its property default, minus `replay`. */
19
- type ProvidedCheckDefaults = Omit<Arbitrary.CheckOptions, 'replay'>;
20
- //#endregion
21
14
  //#region src/internal/virtual-time.d.ts
22
15
  /** @internal */
23
16
  interface VirtualRuntime {
@@ -132,7 +125,7 @@ declare const describeWrapped$1: {
132
125
  (f: (it: Vitest.Methods) => void): (name: string) => V.SuiteCollector;
133
126
  };
134
127
  declare namespace mod_d_exports {
135
- export { Asserted, Check, Checks, Expect, Gate, Vitest, VitestTestContext, addEqualityTesters, afterAll, afterEach, assertType, beforeAll, beforeEach, describe, describeWrapped, expectTypeOf, flakyTest, inject, it, law, layer, makeMethods, onTestFailed, onTestFinished, prop, recordArtifact, test, vi, vitest, vitestTestContextKey };
128
+ export { Asserted, Check, Checks, CoverageBelowMinimum, Expect, Gate, NonBooleanVerdict, PropertyBudget, PropertyRefuted, ReplayUnreadable, SeedStoreUnreadable, SelfModelLaw, VacuousProperty, Vitest, VitestTestContext, addEqualityTesters, afterAll, afterEach, assertType, beforeAll, beforeEach, describe, describeWrapped, expectTypeOf, flakyTest, inject, it, law, layer, makeMethods, onTestFailed, onTestFinished, prop, recordArtifact, test, vi, vitest, vitestTestContextKey };
136
129
  }
137
130
  declare module 'vitest' {
138
131
  interface ProvidedContext {
@@ -495,4 +488,4 @@ export declare const VitestTestContext: Context.Reference<V.TestContext | null>;
495
488
  */
496
489
  export type Gate<R, Provided = never> = Vitest.Gate<R, Provided>;
497
490
  //#endregion
498
- export { type Asserted, type Check, type Checks, type Expect, afterAll, assertType, beforeAll, expectTypeOf, inject, onTestFailed, onTestFinished, recordArtifact, vi, vitest };
491
+ export { type Asserted, type Check, type Checks, CoverageBelowMinimum, type Expect, NonBooleanVerdict, type PropertyBudget, PropertyRefuted, ReplayUnreadable, SeedStoreUnreadable, SelfModelLaw, VacuousProperty, afterAll, assertType, beforeAll, expectTypeOf, inject, onTestFailed, onTestFinished, recordArtifact, vi, vitest };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as replayOfFailure, d as providedRoot, f as InvalidBudget, h as Slop, i as makeProperty, l as testIdentityOf, m as NonBooleanVerdict, o as isFailureRecordError, p as LeakedState, r as createSpanRecorder, u as throwFailureRecord } from "./failure-D8mPXwf4.mjs";
2
+ import { C as Slop, D as providedCheckDefaults, S as LeakedState, _ as testIdentityOf, a as makeProperty, b as providedRoot, c as NonBooleanVerdict, d as SeedStoreUnreadable, f as SelfModelLaw, i as createSpanRecorder, l as PropertyRefuted, m as isFailureRecordError, o as makeFileLedger, p as VacuousProperty, s as CoverageBelowMinimum, u as ReplayUnreadable, v as throwFailureRecord, x as InvalidBudget } from "./failure-nvq5TwWX.mjs";
3
3
  import { a as isCheck, i as checksFor, n as vitestTestContextKey$1, o as makeLedger, r as Asserted, t as VitestTestContext$1 } from "./test-context-D_-acRSc.mjs";
4
4
  import { _ as refuseScopedLiveLane, d as refuseAsyncBody, f as refuseEffectLane, g as refuseScopedLane, i as markTask, l as noCheckRefusal, o as isRefusal$1, p as refuseHook, u as refusalOf$1, v as refuseSyncBody, x as unprovidedText, y as refuseUnyielded } from "./guard-BocOhXt2.mjs";
5
5
  import * as V from "vitest";
@@ -374,7 +374,7 @@ const throwRecorded = (cause, recorder, ctx) => {
374
374
  failure,
375
375
  spans: recorder.spans,
376
376
  identity: testIdentityOf(ctx.task),
377
- replay: replayOfFailure(failure),
377
+ replay: void 0,
378
378
  root: providedRoot()
379
379
  });
380
380
  };
@@ -462,14 +462,26 @@ const NO_ERRORS = [];
462
462
  const presentErrors = (errors) => errors === void 0 ? NO_ERRORS : errors;
463
463
  /** Whether a run left no failure behind: only a clean first run is worth running a second time. */
464
464
  const isClean = (ctx) => presentErrors(ctx.task.result?.errors).length === 0;
465
+ const propertyTaskOf = (ctx) => ({
466
+ identity: testIdentityOf(ctx.task),
467
+ filepath: ctx.task.file.filepath,
468
+ budget: providedCheckDefaults()
469
+ });
465
470
  /**
466
471
  * Runs a property's program as the test that registered it, under the same context the generator lanes use. The
467
472
  * env is the bare `propertyEnv`: a `false` verdict is the property's own shrink path, so nothing interrupts it.
468
473
  */
469
- const runProperty = (ctx, program) => runRecorded(bindRun(Effect.suspend(program), ctx), ctx, propertyEnv);
474
+ const runProperty = (ctx, program) => runRecorded(bindRun(Effect.suspend(() => program(propertyTaskOf(ctx))), ctx), ctx, propertyEnv);
475
+ /** The sync and effect property lanes of one test file share this ledger; it is judged once, at file end (R20). */
476
+ const propertyLedger = makeFileLedger();
477
+ V.afterAll(() => {
478
+ const refused = propertyLedger.finalise();
479
+ if (refused !== void 0) throw new VacuousProperty(refused);
480
+ });
470
481
  const property = makeProperty({
471
482
  register: (name, program) => marked(() => V.it(name, (ctx) => runProperty(ctx, program))),
472
- provide: (effect) => effect
483
+ provide: (effect) => effect,
484
+ ledger: propertyLedger
473
485
  });
474
486
  const propImpl = (name, spec, holds) => {
475
487
  refusePositional(spec);
@@ -676,7 +688,8 @@ const makeTesterWith = (mapEffect, it, envFor, rerunnable) => {
676
688
  };
677
689
  const effectProperty = makeProperty({
678
690
  register: (name, program) => marked(() => it(name, (ctx) => runProperty(ctx, program))),
679
- provide: (effect) => mapEffect(effect, envFor())
691
+ provide: (effect) => mapEffect(effect, envFor()),
692
+ ledger: propertyLedger
680
693
  });
681
694
  const prop = (name, spec, holds) => {
682
695
  refusePositional(spec);
@@ -838,4 +851,4 @@ const vitestTestContextKey = vitestTestContextKey$1;
838
851
  */
839
852
  const VitestTestContext = VitestTestContext$1;
840
853
  //#endregion
841
- export { VitestTestContext, addEqualityTesters, afterAll, afterEach, assertType, beforeAll, beforeEach, describe, describeWrapped, expectTypeOf, flakyTest, inject, it, law, layer, makeMethods, onTestFailed, onTestFinished, prop, recordArtifact, test, vi, vitest, vitestTestContextKey };
854
+ export { CoverageBelowMinimum, NonBooleanVerdict, PropertyRefuted, ReplayUnreadable, SeedStoreUnreadable, SelfModelLaw, VacuousProperty, VitestTestContext, addEqualityTesters, afterAll, afterEach, assertType, beforeAll, beforeEach, describe, describeWrapped, expectTypeOf, flakyTest, inject, it, law, layer, makeMethods, onTestFailed, onTestFinished, prop, recordArtifact, test, vi, vitest, vitestTestContextKey };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/vitest",
3
3
  "license": "MIT",
4
- "version": "1.0.0",
4
+ "version": "2.0.0",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -46,6 +46,9 @@
46
46
  "files": [
47
47
  "dist"
48
48
  ],
49
+ "dependencies": {
50
+ "@effect/platform-node": "^4"
51
+ },
49
52
  "devDependencies": {
50
53
  "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
51
54
  "@systemfsoftware/oxlint-config-recommended": "^4.0.0",
@@ -1,166 +0,0 @@
1
-
2
- import * as Cause from "effect/Cause";
3
- import * as Effect$1 from "effect/Effect";
4
- import * as Schema$1 from "effect/Schema";
5
- import { Schema } from "effect";
6
- import * as Arbitrary from "effect/Arbitrary";
7
- //#endregion
8
- //#region src/internal/errors.schema.d.ts
9
- /**
10
- * The contract rules a rendered failure record can break (R10, KTD7).
11
- *
12
- * @internal
13
- */
14
- declare const Breach: Schema.Literals<readonly ["R1", "R2", "R6"]>;
15
- /** @internal */
16
- type Breach = typeof Breach.Type;
17
- declare const NonBooleanVerdict_base: Schema.Class<NonBooleanVerdict, Schema.TaggedStruct<"NonBooleanVerdict", {
18
- readonly detail: Schema.String;
19
- }>, import("effect/Cause").YieldableError>;
20
- /** @internal */
21
- declare class NonBooleanVerdict extends NonBooleanVerdict_base {
22
- get message(): string;
23
- }
24
- //#endregion
25
- //#region src/internal/property/impostor.d.ts
26
- /**
27
- * @internal The constant impostor of R12: a fake of the subject under test that
28
- * returns the first output it ever produced, for every later call, whatever the
29
- * input it was given.
30
- *
31
- * A property that still holds for the impostor does not constrain the subject.
32
- * Whether that is fatal is a per-file question — a subject's impostor must be
33
- * refuted by some property in its file — so this module builds the fake and
34
- * collects the verdicts; the engine decides them once, when the file finishes
35
- * (KTD10).
36
- */
37
- /**
38
- * A value the fork hands over without inspecting: an argument to the subject, or one of its outputs.
39
- *
40
- * @internal
41
- */
42
- type Opaque<A = unknown> = A;
43
- /**
44
- * A function under test: any argument, any output.
45
- *
46
- * @internal
47
- */
48
- type SubjectFunction = (...values: ReadonlyArray<never>) => Opaque;
49
- /**
50
- * A record of functions under test; every member is replaced by a constant.
51
- *
52
- * @internal
53
- */
54
- type MemberRecord = {
55
- readonly [key: string]: SubjectFunction;
56
- };
57
- /**
58
- * The function under test, or a record of them.
59
- *
60
- * @internal
61
- */
62
- type Subject = SubjectFunction | MemberRecord;
63
- declare namespace kinds_d_exports {
64
- export { LawApi, LawKind, LawSubject, MetamorphicRelation, deterministicHolds, idempotentHolds, invariantHolds, metamorphicHolds, modelHolds, roundTripHolds, spreadValues };
65
- }
66
- /** @internal */
67
- type LawKind = 'model' | 'metamorphic' | 'roundTrip' | 'invariant' | 'idempotent' | 'deterministic';
68
- /**
69
- * A subject of a law kind: a function of the generated values.
70
- *
71
- * @internal
72
- */
73
- type LawSubject<G extends Gens, A> = (...values: ReadonlyArray<ElementValues<G>>) => A;
74
- /**
75
- * A metamorphic relation: the input transform, and how the two outputs relate (structural equality by default).
76
- *
77
- * @internal
78
- */
79
- interface MetamorphicRelation<G extends Gens, A> {
80
- readonly transform: (...values: ReadonlyArray<ElementValues<G>>) => Values<G>;
81
- readonly relate?: (original: A, transformed: A) => boolean;
82
- }
83
- /**
84
- * The R13 law surface: four gated kinds and two declared exemptions.
85
- *
86
- * @internal
87
- */
88
- interface LawApi {
89
- readonly model: <const G extends Gens, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec<G, S, N>, oracle: LawSubject<G, A>) => void;
90
- readonly metamorphic: <const G extends Gens, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec<G, S, N>, relation: MetamorphicRelation<G, A>) => void;
91
- readonly roundTrip: <const G extends Gens, E, N extends number, S extends LawSubject<G, E>>(name: string, spec: PropertySpec<G, S, N>, decode: (encoded: E) => Values<G>) => void;
92
- readonly invariant: <const G extends Gens, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec<G, S, N>, holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => void;
93
- readonly idempotent: <const G extends Gens, N extends number, S extends (value: ElementValues<G>) => ElementValues<G>>(name: string, spec: PropertySpec<G, S, N>) => void;
94
- readonly deterministic: <const G extends Gens, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec<G, S, N>) => void;
95
- }
96
- /**
97
- * The generated values as the argument list a law subject is called with.
98
- *
99
- * @internal
100
- */
101
- declare const spreadValues: <G extends Gens>(values: Values<G>) => ReadonlyArray<ElementValues<G>>;
102
- /** @internal */
103
- declare const modelHolds: <G extends Gens, A>(oracle: LawSubject<G, A>) => (subject: LawSubject<G, A>, values: Values<G>) => boolean;
104
- /** @internal */
105
- declare const metamorphicHolds: <G extends Gens, A>(relation: MetamorphicRelation<G, A>) => (subject: LawSubject<G, A>, values: Values<G>) => boolean;
106
- /** @internal */
107
- declare const roundTripHolds: <G extends Gens, E>(decode: (encoded: E) => Values<G>) => (subject: LawSubject<G, E>, values: Values<G>) => boolean;
108
- /** @internal */
109
- declare const invariantHolds: <G extends Gens, A>(holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => (subject: LawSubject<G, A>, values: Values<G>) => boolean;
110
- /** @internal */
111
- declare const idempotentHolds: <G extends Gens>() => (subject: (value: ElementValues<G>) => ElementValues<G>, values: Values<G>) => boolean;
112
- /** @internal */
113
- declare const deterministicHolds: <G extends Gens, A>() => (subject: LawSubject<G, A>, values: Values<G>) => boolean;
114
- declare namespace engine_d_exports {
115
- export { ArbitraryInput, CoveragePredicate, ElementValues, Gens, PropApi, PropertyRuntime, PropertySpec, PropertySubject, Values, makeProperty };
116
- }
117
- /** @internal */
118
- type ArbitraryInput = Schema$1.Top | Arbitrary.Arbitrary<Schema$1.Top['Type']>;
119
- /** @internal */
120
- type Gens = ReadonlyArray<ArbitraryInput> | {
121
- readonly [key: string]: ArbitraryInput;
122
- };
123
- type Generated<I> = I extends Schema$1.Schema<infer T> ? T : I extends Arbitrary.Arbitrary<infer A> ? A : never;
124
- /** @internal */
125
- type Values<G extends Gens> = { readonly [K in keyof G]: Generated<G[K]>; };
126
- /** @internal */
127
- type ElementValues<G extends Gens> = G extends ReadonlyArray<ArbitraryInput> ? Generated<G[number]> : never;
128
- /** @internal */
129
- type PropertySubject = Subject;
130
- /** @internal */
131
- type CoveragePredicate<G extends Gens> = (...values: ReadonlyArray<ElementValues<G>>) => boolean;
132
- type PropertyRuns<N extends number> = number extends N ? number : `${N}` extends `-${bigint}` ? never : `${N}` extends `${bigint}` ? (N extends 0 ? never : N) : never;
133
- /** @internal */
134
- interface PropertySpec<G extends Gens, S extends PropertySubject, N extends number> {
135
- readonly of: G;
136
- readonly subject: S;
137
- /**
138
- * The property's own run count. Omitted, the configured default applies; when the run provides none,
139
- * the built-in default of 100 does.
140
- */
141
- readonly runs?: N & PropertyRuns<N>;
142
- /** Labelled input predicates, each with the minimum share of runs it must see (R14). */
143
- readonly cover?: Readonly<Record<string, readonly [CoveragePredicate<G>, number]>>;
144
- /** The property's own check options, merged field by field over the provided and built-in defaults. */
145
- readonly arbitrary?: Arbitrary.CheckOptions;
146
- }
147
- /** @internal */
148
- interface PropertyRuntime<R> {
149
- /** Registers the property's program; the runtime runs it inside the test it registers, under that test's binding. */
150
- readonly register: (name: string, program: () => Effect$1.Effect<void, Cause.Cause<NonBooleanVerdict>, never>) => void;
151
- readonly provide: <A, E>(effect: Effect$1.Effect<A, E, R>) => Effect$1.Effect<A, E, never>;
152
- }
153
- /** @internal */
154
- interface PropApi<R> {
155
- readonly prop: <const G extends Gens, S extends PropertySubject, N extends number>(name: string, spec: PropertySpec<G, S, N>, holds: (subject: S, values: Values<G>) => boolean) => void;
156
- readonly effectProp: <const G extends Gens, S extends PropertySubject, N extends number, E>(name: string, spec: PropertySpec<G, S, N>, holds: (subject: S, values: Values<G>) => Effect$1.Effect<boolean, E, R>) => void;
157
- readonly law: LawApi;
158
- }
159
- /**
160
- * The property surface over one runtime: `prop`, `effectProp`, and the R13 law kinds routed through the gate.
161
- *
162
- * @internal
163
- */
164
- declare const makeProperty: <R>(runtime: PropertyRuntime<R>) => PropApi<R>;
165
- //#endregion
166
- export { Values as a, kinds_d_exports as c, PropertySubject as i, Breach as l, Gens as n, engine_d_exports as o, PropertySpec as r, LawApi as s, ArbitraryInput as t, __exportAll as u };