@systemfsoftware/vitest 0.1.0 → 0.2.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.
@@ -0,0 +1,80 @@
1
+
2
+ import { a as Values, i as PropertySubject, n as Gens, o as engine_d_exports, r as PropertySpec } from "./engine-YsoQ_9we.js";
3
+ import { S as summaryOf, _ as FailureRecord, b as TestIdentity, g as Breach, h as AttributeValue, i as Checks, t as Asserted, v as FailureRecordInput, x as renderFailureRecord, y as ReplayValue } from "./checks-Cq9of-Lx.js";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Tracer from "effect/Tracer";
6
+ //#region src/internal/call-site.d.ts
7
+ /** @internal */
8
+ export declare const callFrameOutside: (library: RegExp) => string | undefined;
9
+ /** @internal */
10
+ export declare const callSite: () => string | undefined;
11
+ /** @internal */
12
+ export declare const withRaisingFrame: {
13
+ <A extends Error>(error: A, frame: string | undefined): A;
14
+ (frame: string | undefined): <A extends Error>(error: A) => A;
15
+ };
16
+ //#endregion
17
+ //#region src/internal/failure-error.d.ts
18
+ /**
19
+ * Renders the record and throws what Vitest prints for it: the record itself when it holds its contract, a
20
+ * `FailureRecordRefused` when it breaks one, and a refusal passed in unchanged, so refusing cannot recurse (R10).
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const throwFailureRecord: <E>(input: FailureRecordInput<E>) => never;
25
+ //#endregion
26
+ //#region src/internal/failure-identity.d.ts
27
+ /** The fields this reads off a Vitest task: every one optional, so a partial context yields an incomplete identity. */
28
+ interface TaskLike {
29
+ readonly name?: string | undefined;
30
+ readonly fullName?: string | undefined;
31
+ readonly fullTestName?: string | undefined;
32
+ }
33
+ /**
34
+ * The identity of the test being run, or of the task handed in. A run outside a test, or one whose task carries
35
+ * no file, yields an incomplete identity, which the renderer reports as the R6 breach it is.
36
+ *
37
+ * @internal
38
+ */
39
+ export declare const testIdentityOf: (task?: TaskLike | null) => TestIdentity;
40
+ //#endregion
41
+ //#region src/internal/provided.d.ts
42
+ /** @internal */
43
+ declare const providedRoot: () => string | undefined;
44
+ //#endregion
45
+ //#region src/internal/recorded-run.d.ts
46
+ /** @internal */
47
+ interface RecordedRun<A, E> {
48
+ (checks: Checks): Effect.Effect<A, E, Asserted>;
49
+ }
50
+ /** @internal */
51
+ interface RecordedProperty<G extends Gens, S extends PropertySubject, N extends number> {
52
+ readonly name: string;
53
+ readonly spec: PropertySpec<G, S, N>;
54
+ readonly holds: (subject: S, values: Values<G>) => boolean;
55
+ }
56
+ /**
57
+ * Runs one program as the runner runs a lane, with a fresh ledger and its own recorder, and resolves with the
58
+ * record its failure rendered — or `undefined` when it passed.
59
+ *
60
+ * @internal
61
+ */
62
+ export declare const recordOfRun: <A, E>(program: RecordedRun<A, E>) => Promise<FailureRecord | undefined>;
63
+ /**
64
+ * Runs one property the way the runner runs `it.prop`, with a fresh ledger and its own recorder, and resolves with
65
+ * the record its falsification rendered — or `undefined` when it held.
66
+ *
67
+ * @internal
68
+ */
69
+ export declare const recordOfProperty: <const G extends Gens, S extends PropertySubject, N extends number>(input: RecordedProperty<G, S, N>) => Promise<FailureRecord | undefined>;
70
+ //#endregion
71
+ //#region src/internal/span-recorder.d.ts
72
+ /** @internal */
73
+ interface SpanRecorder {
74
+ readonly tracer: Tracer.Tracer;
75
+ readonly spans: ReadonlyArray<Tracer.NativeSpan>;
76
+ }
77
+ /** @internal */
78
+ export declare const createSpanRecorder: () => SpanRecorder;
79
+ //#endregion
80
+ export { type AttributeValue, type Breach, type FailureRecord, type FailureRecordInput, type RecordedProperty, type RecordedRun, type ReplayValue, type SpanRecorder, type TestIdentity, providedRoot as providedWorkspaceRoot, renderFailureRecord, summaryOf };
@@ -0,0 +1,4 @@
1
+
2
+ import { d as summaryOf, l as throwFailureRecord, n as recordOfRun, o as testIdentityOf, r as createSpanRecorder, s as providedRoot, t as recordOfProperty, u as renderFailureRecord } from "./failure-BquJJPFZ.mjs";
3
+ import { c as callFrameOutside, l as callSite, p as withRaisingFrame } from "./test-context-ChvjVyCo.mjs";
4
+ export { callFrameOutside, callSite, createSpanRecorder, providedRoot as providedWorkspaceRoot, recordOfProperty, recordOfRun, renderFailureRecord, summaryOf, testIdentityOf, throwFailureRecord, withRaisingFrame };
@@ -2,16 +2,6 @@
2
2
  import { chai } from "vitest";
3
3
  //#region src/internal/refusals.ts
4
4
  /**
5
- * Every refusal the fork prints, as the one text it uses on both channels: the `this` type (or parameter union)
6
- * the compiler prints at the call site, and the message thrown at run time.
7
- *
8
- * Surface: `it(name, function* ({ expect }) { ... })`. Ported verbatim from the prototype's `checks.ts`; the
9
- * prototype's `test(` surfaces are rewritten to `it(`, and `refusedText` gained the `expect` statics
10
- * (`.resolves`, `.rejects`, `expect.anything`, `expect.poll`, `expect.soft`).
11
- *
12
- * @since 4.0.0
13
- */
14
- /**
15
5
  * The brand every run-time refusal carries. A test is run a second time on a fresh build to catch leaked state,
16
6
  * so when that second run fails with a refusal the fork itself made, the runner re-throws the refusal rather than
17
7
  * relabelling it as a leak (see `throwSecondRun` in `runner.ts`). The brand is a `Symbol.for` value because a
@@ -91,6 +81,20 @@ const refuseHook = "✗ hooks share state between tests. Build what a test needs
91
81
  const refuseRawExpect = "✗ an expect imported from vitest ran; take it from the test callback: it(name, function* ({ expect }) { ... })";
92
82
  /** @internal */
93
83
  const refuseRawIt = "✗ this test was registered with vitest's it; import it from @systemfsoftware/vitest";
84
+ /**
85
+ * The fixed prose each breach of the record contract is refused with (R10, KTD7). A refusal carries this text and
86
+ * nothing from the record itself, and nothing ever reads it back, so a refusal cannot recurse. The breach letter is
87
+ * not printed: a reader acts on what is missing, not on which requirement numbered it.
88
+ */
89
+ /** @internal */
90
+ const refusedRecordText = {
91
+ R1: "the headline is empty",
92
+ R2: "the record names no source location",
93
+ R6: "a replay value names a run no generator chose, or the rerun line is missing"
94
+ };
95
+ /** The one detail a record refusal carries: every breach the renderer found, in the prose above (R10). */
96
+ /** @internal */
97
+ const refusedRecordDetail = (breaches) => `✗ refused a failure record: ${breaches.map((breach) => refusedRecordText[breach]).join(", and ")}`;
94
98
  //#endregion
95
99
  //#region src/internal/guard.ts
96
100
  /**
@@ -243,4 +247,4 @@ const installGuard = () => {
243
247
  patchExtend();
244
248
  };
245
249
  //#endregion
246
- export { refuseScopedLiveLane as _, booleanRefusal as a, refusedText as b, negatedText as c, refuseAsyncBody as d, refuseEffectLane as f, refuseScopedLane as g, refuseRawIt as h, markTask as i, noCheckRefusal as l, refusePiecewise as m, installGuard as n, isRefusal as o, refuseHook as p, isMarked as r, neededText as s, authorize as t, refusalOf as u, refuseSyncBody as v, unprovidedText as x, refuseUnyielded as y };
250
+ export { unprovidedText as S, refuseScopedLiveLane as _, booleanRefusal as a, refusedRecordDetail as b, negatedText as c, refuseAsyncBody as d, refuseEffectLane as f, refuseScopedLane as g, refuseRawIt as h, markTask as i, noCheckRefusal as l, refusePiecewise as m, installGuard as n, isRefusal as o, refuseHook as p, isMarked as r, neededText as s, authorize as t, refusalOf as u, refuseSyncBody as v, refusedText as x, refuseUnyielded as y };
package/dist/guard.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { h as refuseRawIt, n as installGuard, r as isMarked, u as refusalOf } from "./guard-BocOhXt2.mjs";
2
+ import { h as refuseRawIt, n as installGuard, r as isMarked, u as refusalOf } from "./guard-p_8ARgPm.mjs";
3
3
  import { beforeEach } from "vitest";
4
4
  //#region src/guard.ts
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,176 +1,23 @@
1
1
  /// <reference types="./compat.d.ts" />
2
- 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";
2
+ import { a as Values$1, c as kinds_d_exports, i as PropertySubject$1, l as __exportAll, n as Gens$1, o as engine_d_exports, r as PropertySpec$1, s as LawApi, t as ArbitraryInput } from "./engine-YsoQ_9we.js";
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-Cq9of-Lx.js";
3
4
  import * as V from "vitest";
4
5
  import { afterAll, assertType, beforeAll, expectTypeOf, inject, onTestFailed, onTestFinished, recordArtifact, vi, vitest } from "vitest";
5
- import * as Cause from "effect/Cause";
6
6
  import * as Duration from "effect/Duration";
7
7
  import * as Effect from "effect/Effect";
8
8
  import * as Layer from "effect/Layer";
9
- import * as Schema$1 from "effect/Schema";
10
9
  import * as Scope from "effect/Scope";
11
10
  import * as TestConsole from "effect/testing/TestConsole";
12
11
  import * as Context from "effect/Context";
13
- import { Schema } from "effect";
14
12
  import * as Arbitrary from "effect/unstable/arbitrary/Arbitrary";
15
13
  import * as Clock from "effect/Clock";
16
14
  import * as Scheduler from "effect/Scheduler";
17
- //#endregion
18
15
  //#region src/internal/property/defaults.d.ts
19
16
  /** @internal The `test.provide` key the shared config fills with this run's tier's check options. */
20
17
  declare const checkDefaultsKey = "@systemfsoftware/vitest:property-check";
21
18
  /** @internal The check options a run supplies as its property default, minus `replay`. */
22
19
  type ProvidedCheckDefaults = Omit<Arbitrary.CheckOptions, 'replay'>;
23
20
  //#endregion
24
- //#region src/internal/errors.schema.d.ts
25
- declare const NonBooleanVerdict_base: Schema.Class<NonBooleanVerdict, Schema.TaggedStruct<"NonBooleanVerdict", {
26
- readonly detail: Schema.String;
27
- }>, import("effect/Cause").YieldableError>;
28
- /** @internal */
29
- declare class NonBooleanVerdict extends NonBooleanVerdict_base {
30
- get message(): string;
31
- }
32
- //#endregion
33
- //#region src/internal/property/impostor.d.ts
34
- /**
35
- * @internal The constant impostor of R12: a fake of the subject under test that
36
- * returns the first output it ever produced, for every later call, whatever the
37
- * input it was given.
38
- *
39
- * A property that still holds for the impostor does not constrain the subject.
40
- * Whether that is fatal is a per-file question — a subject's impostor must be
41
- * refuted by some property in its file — so this module builds the fake and
42
- * collects the verdicts; the engine decides them once, when the file finishes
43
- * (KTD10).
44
- */
45
- /**
46
- * A value the fork hands over without inspecting: an argument to the subject, or one of its outputs.
47
- *
48
- * @internal
49
- */
50
- type Opaque<A = unknown> = A;
51
- /**
52
- * A function under test: any argument, any output.
53
- *
54
- * @internal
55
- */
56
- type SubjectFunction = (...values: ReadonlyArray<never>) => Opaque;
57
- /**
58
- * A record of functions under test; every member is replaced by a constant.
59
- *
60
- * @internal
61
- */
62
- type MemberRecord = {
63
- readonly [key: string]: SubjectFunction;
64
- };
65
- /**
66
- * The function under test, or a record of them.
67
- *
68
- * @internal
69
- */
70
- type Subject = SubjectFunction | MemberRecord;
71
- declare namespace kinds_d_exports {
72
- export { LawApi, LawKind, LawSubject, MetamorphicRelation, deterministicHolds, idempotentHolds, invariantHolds, metamorphicHolds, modelHolds, roundTripHolds, spreadValues };
73
- }
74
- /** @internal */
75
- type LawKind = 'model' | 'metamorphic' | 'roundTrip' | 'invariant' | 'idempotent' | 'deterministic';
76
- /**
77
- * A subject of a law kind: a function of the generated values.
78
- *
79
- * @internal
80
- */
81
- type LawSubject<G extends Gens$1, A> = (...values: ReadonlyArray<ElementValues<G>>) => A;
82
- /**
83
- * A metamorphic relation: the input transform, and how the two outputs relate (structural equality by default).
84
- *
85
- * @internal
86
- */
87
- interface MetamorphicRelation<G extends Gens$1, A> {
88
- readonly transform: (...values: ReadonlyArray<ElementValues<G>>) => Values$1<G>;
89
- readonly relate?: (original: A, transformed: A) => boolean;
90
- }
91
- /**
92
- * The R13 law surface: four gated kinds and two declared exemptions.
93
- *
94
- * @internal
95
- */
96
- interface LawApi {
97
- readonly model: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, oracle: LawSubject<G, A>) => void;
98
- readonly metamorphic: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, relation: MetamorphicRelation<G, A>) => void;
99
- readonly roundTrip: <const G extends Gens$1, E, N extends number, S extends LawSubject<G, E>>(name: string, spec: PropertySpec$1<G, S, N>, decode: (encoded: E) => Values$1<G>) => void;
100
- readonly invariant: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => void;
101
- readonly idempotent: <const G extends Gens$1, N extends number, S extends (value: ElementValues<G>) => ElementValues<G>>(name: string, spec: PropertySpec$1<G, S, N>) => void;
102
- readonly deterministic: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>) => void;
103
- }
104
- /**
105
- * The generated values as the argument list a law subject is called with.
106
- *
107
- * @internal
108
- */
109
- declare const spreadValues: <G extends Gens$1>(values: Values$1<G>) => ReadonlyArray<ElementValues<G>>;
110
- /** @internal */
111
- declare const modelHolds: <G extends Gens$1, A>(oracle: LawSubject<G, A>) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
112
- /** @internal */
113
- declare const metamorphicHolds: <G extends Gens$1, A>(relation: MetamorphicRelation<G, A>) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
114
- /** @internal */
115
- declare const roundTripHolds: <G extends Gens$1, E>(decode: (encoded: E) => Values$1<G>) => (subject: LawSubject<G, E>, values: Values$1<G>) => boolean;
116
- /** @internal */
117
- declare const invariantHolds: <G extends Gens$1, A>(holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
118
- /** @internal */
119
- declare const idempotentHolds: <G extends Gens$1>() => (subject: (value: ElementValues<G>) => ElementValues<G>, values: Values$1<G>) => boolean;
120
- /** @internal */
121
- declare const deterministicHolds: <G extends Gens$1, A>() => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
122
- declare namespace engine_d_exports {
123
- export { ArbitraryInput, CoveragePredicate, ElementValues, Gens$1 as Gens, PropApi, PropertyRuntime, PropertySpec$1 as PropertySpec, PropertySubject$1 as PropertySubject, Values$1 as Values, makeProperty };
124
- }
125
- /** @internal */
126
- type ArbitraryInput = Schema$1.Top | Arbitrary.Arbitrary<Schema$1.Top['Type']>;
127
- /** @internal */
128
- type Gens$1 = ReadonlyArray<ArbitraryInput> | {
129
- readonly [key: string]: ArbitraryInput;
130
- };
131
- type Generated<I> = I extends Schema$1.Schema<infer T> ? T : I extends Arbitrary.Arbitrary<infer A> ? A : never;
132
- /** @internal */
133
- type Values$1<G extends Gens$1> = { readonly [K in keyof G]: Generated<G[K]>; };
134
- /** @internal */
135
- type ElementValues<G extends Gens$1> = G extends ReadonlyArray<ArbitraryInput> ? Generated<G[number]> : never;
136
- /** @internal */
137
- type PropertySubject$1 = Subject;
138
- /** @internal */
139
- type CoveragePredicate<G extends Gens$1> = (...values: ReadonlyArray<ElementValues<G>>) => boolean;
140
- type PropertyRuns<N extends number> = number extends N ? number : `${N}` extends `-${bigint}` ? never : `${N}` extends `${bigint}` ? (N extends 0 ? never : N) : never;
141
- /** @internal */
142
- interface PropertySpec$1<G extends Gens$1, S extends PropertySubject$1, N extends number> {
143
- readonly of: G;
144
- readonly subject: S;
145
- /**
146
- * The property's own run count. Omitted, the configured default applies; when the run provides none,
147
- * the built-in default of 100 does.
148
- */
149
- readonly runs?: N & PropertyRuns<N>;
150
- /** Labelled input predicates, each with the minimum share of runs it must see (R14). */
151
- readonly cover?: Readonly<Record<string, readonly [CoveragePredicate<G>, number]>>;
152
- /** The property's own check options, merged field by field over the provided and built-in defaults. */
153
- readonly arbitrary?: Arbitrary.CheckOptions;
154
- }
155
- /** @internal */
156
- interface PropertyRuntime<R> {
157
- /** Registers the property's program; the runtime runs it inside the test it registers, under that test's binding. */
158
- readonly register: (name: string, program: () => Effect.Effect<void, Cause.Cause<NonBooleanVerdict>, never>) => void;
159
- readonly provide: <A, E>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, never>;
160
- }
161
- /** @internal */
162
- interface PropApi<R> {
163
- readonly prop: <const G extends Gens$1, S extends PropertySubject$1, N extends number>(name: string, spec: PropertySpec$1<G, S, N>, holds: (subject: S, values: Values$1<G>) => boolean) => void;
164
- readonly effectProp: <const G extends Gens$1, S extends PropertySubject$1, N extends number, E>(name: string, spec: PropertySpec$1<G, S, N>, holds: (subject: S, values: Values$1<G>) => Effect.Effect<boolean, E, R>) => void;
165
- readonly law: LawApi;
166
- }
167
- /**
168
- * The property surface over one runtime: `prop`, `effectProp`, and the R13 law kinds routed through the gate.
169
- *
170
- * @internal
171
- */
172
- declare const makeProperty: <R>(runtime: PropertyRuntime<R>) => PropApi<R>;
173
- //#endregion
174
21
  //#region src/internal/virtual-time.d.ts
175
22
  /** @internal */
176
23
  interface VirtualRuntime {
@@ -290,6 +137,8 @@ declare namespace mod_d_exports {
290
137
  declare module 'vitest' {
291
138
  interface ProvidedContext {
292
139
  [checkDefaultsKey]?: ProvidedCheckDefaults;
140
+ '@systemfsoftware/vitest:package'?: string;
141
+ '@systemfsoftware/vitest:workspace-root'?: string;
293
142
  }
294
143
  }
295
144
  /**