@effect/vitest 0.26.0 → 4.0.0-beta.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.
@@ -1,68 +1,45 @@
1
- import * as Arbitrary from "effect/Arbitrary";
1
+ /**
2
+ * @since 1.0.0
3
+ */
2
4
  import * as Cause from "effect/Cause";
3
5
  import * as Duration from "effect/Duration";
4
6
  import * as Effect from "effect/Effect";
5
- import * as Equal from "effect/Equal";
6
7
  import * as Exit from "effect/Exit";
7
- import * as fc from "effect/FastCheck";
8
- import * as Fiber from "effect/Fiber";
9
- import { flow, identity, pipe } from "effect/Function";
8
+ import { flow, pipe } from "effect/Function";
10
9
  import * as Layer from "effect/Layer";
11
- import * as Logger from "effect/Logger";
12
10
  import { isObject } from "effect/Predicate";
13
11
  import * as Schedule from "effect/Schedule";
14
12
  import * as Schema from "effect/Schema";
15
13
  import * as Scope from "effect/Scope";
16
- import * as TestEnvironment from "effect/TestContext";
17
- import * as Utils from "effect/Utils";
14
+ import * as fc from "effect/testing/FastCheck";
15
+ import * as TestClock from "effect/testing/TestClock";
16
+ import * as TestConsole from "effect/testing/TestConsole";
18
17
  import * as V from "vitest";
19
- const defaultApi = /*#__PURE__*/Object.assign(V.it, {
20
- scopedFixtures: V.it.scoped
21
- });
22
- const runPromise = ctx => effect => Effect.gen(function* () {
23
- const exitFiber = yield* Effect.fork(Effect.exit(effect));
24
- ctx?.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise));
25
- const exit = yield* Fiber.join(exitFiber);
26
- if (Exit.isSuccess(exit)) {
27
- return () => exit.value;
28
- } else {
29
- if (Cause.isInterruptedOnly(exit.cause)) {
30
- return () => {
31
- throw new Error("All fibers interrupted without errors.");
32
- };
33
- }
18
+ const runPromise = /*#__PURE__*/Effect.fnUntraced(function* (effect, _ctx) {
19
+ const exit = yield* Effect.exit(effect);
20
+ if (Exit.isFailure(exit)) {
34
21
  const errors = Cause.prettyErrors(exit.cause);
35
- for (let i = 1; i < errors.length; i++) {
22
+ for (let i = 0; i < errors.length; i++) {
36
23
  yield* Effect.logError(errors[i]);
37
24
  }
38
- return () => {
39
- throw errors[0];
40
- };
41
25
  }
42
- }).pipe(effect => Effect.runPromise(effect, {
26
+ return yield* exit;
27
+ }, (effect, _, ctx) => Effect.runPromise(effect, {
43
28
  signal: ctx?.signal
44
- })).then(f => f());
45
- /** @internal */
46
- const runTest = ctx => effect => runPromise(ctx)(effect);
29
+ }));
47
30
  /** @internal */
48
- const TestEnv = /*#__PURE__*/TestEnvironment.TestContext.pipe(/*#__PURE__*/Layer.provide(/*#__PURE__*/Logger.remove(Logger.defaultLogger)));
49
- /** @internal */
50
- function customTester(a, b, customTesters) {
51
- if (!Equal.isEqual(a) || !Equal.isEqual(b)) {
52
- return undefined;
53
- }
54
- return Utils.structuralRegion(() => Equal.equals(a, b), (x, y) => this.equals(x, y, customTesters.filter(t => t !== customTester)));
55
- }
31
+ const runTest = ctx => effect => runPromise(effect, ctx);
32
+ const TestEnv = /*#__PURE__*/Layer.mergeAll(TestConsole.layer, /*#__PURE__*/TestClock.layer());
56
33
  /** @internal */
57
34
  export const addEqualityTesters = () => {
58
- V.expect.addEqualityTesters([customTester]);
35
+ V.expect.addEqualityTesters([]);
59
36
  };
60
37
  /** @internal */
61
38
  const testOptions = timeout => typeof timeout === "number" ? {
62
39
  timeout
63
40
  } : timeout ?? {};
64
41
  /** @internal */
65
- const makeTester = (mapEffect, it = defaultApi) => {
42
+ const makeTester = (mapEffect, it = V.it) => {
66
43
  const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));
67
44
  const f = (name, self, timeout) => it(name, testOptions(timeout), ctx => run(ctx, [ctx], self));
68
45
  const skip = (name, self, timeout) => it.skip(name, testOptions(timeout), ctx => run(ctx, [ctx], self));
@@ -73,22 +50,35 @@ const makeTester = (mapEffect, it = defaultApi) => {
73
50
  const fails = (name, self, timeout) => V.it.fails(name, testOptions(timeout), ctx => run(ctx, [ctx], self));
74
51
  const prop = (name, arbitraries, self, timeout) => {
75
52
  if (Array.isArray(arbitraries)) {
76
- const arbs = arbitraries.map(arbitrary => Schema.isSchema(arbitrary) ? Arbitrary.make(arbitrary) : arbitrary);
53
+ const arbs = arbitraries.map(arbitrary => {
54
+ if (Schema.isSchema(arbitrary)) {
55
+ return Schema.toArbitrary(arbitrary);
56
+ }
57
+ return arbitrary;
58
+ });
77
59
  return it(name, testOptions(timeout), ctx =>
78
60
  // @ts-ignore
79
61
  fc.assert(
80
62
  // @ts-ignore
81
- fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
63
+ fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)),
64
+ // @ts-ignore
65
+ isObject(timeout) ? timeout?.fastCheck : {}));
82
66
  }
83
67
  const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {
84
- result[key] = Schema.isSchema(arbitraries[key]) ? Arbitrary.make(arbitraries[key]) : arbitraries[key];
68
+ const arb = arbitraries[key];
69
+ if (Schema.isSchema(arb)) {
70
+ result[key] = Schema.toArbitrary(arb);
71
+ }
72
+ result[key] = arb;
85
73
  return result;
86
74
  }, {}));
87
75
  return it(name, testOptions(timeout), ctx =>
88
76
  // @ts-ignore
89
77
  fc.assert(fc.asyncProperty(arbs, (...as) =>
90
78
  // @ts-ignore
91
- run(ctx, [as[0], ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
79
+ run(ctx, [as[0], ctx], self)),
80
+ // @ts-ignore
81
+ isObject(timeout) ? timeout?.fastCheck : {}));
92
82
  };
93
83
  return Object.assign(f, {
94
84
  skip,
@@ -103,13 +93,22 @@ const makeTester = (mapEffect, it = defaultApi) => {
103
93
  /** @internal */
104
94
  export const prop = (name, arbitraries, self, timeout) => {
105
95
  if (Array.isArray(arbitraries)) {
106
- const arbs = arbitraries.map(arbitrary => Schema.isSchema(arbitrary) ? Arbitrary.make(arbitrary) : arbitrary);
96
+ const arbs = arbitraries.map(arbitrary => {
97
+ if (Schema.isSchema(arbitrary)) {
98
+ throw new Error("Schemas are not supported yet");
99
+ }
100
+ return arbitrary;
101
+ });
107
102
  return V.it(name, testOptions(timeout),
108
103
  // @ts-ignore
109
104
  ctx => fc.assert(fc.property(...arbs, (...as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));
110
105
  }
111
106
  const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {
112
- result[key] = Schema.isSchema(arbitraries[key]) ? Arbitrary.make(arbitraries[key]) : arbitraries[key];
107
+ const arb = arbitraries[key];
108
+ if (Schema.isSchema(arb)) {
109
+ throw new Error("Schemas are not supported yet");
110
+ }
111
+ result[key] = arb;
113
112
  return result;
114
113
  }, {}));
115
114
  return V.it(name, testOptions(timeout),
@@ -122,11 +121,10 @@ export const layer = (layer_, options) => (...args) => {
122
121
  const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);
123
122
  const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);
124
123
  const scope = Effect.runSync(Scope.make());
125
- const runtimeEffect = Layer.toRuntimeWithMemoMap(withTestEnv, memoMap).pipe(Scope.extend(scope), Effect.orDie, Effect.cached, Effect.runSync);
124
+ const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);
126
125
  const makeIt = it => Object.assign(it, {
127
- effect: makeTester(effect => Effect.flatMap(runtimeEffect, runtime => effect.pipe(Effect.provide(runtime))), it),
126
+ effect: makeTester(effect => Effect.flatMap(contextEffect, context => effect.pipe(Effect.scoped, Effect.provide(context))), it),
128
127
  prop,
129
- scoped: makeTester(effect => Effect.flatMap(runtimeEffect, runtime => effect.pipe(Effect.scoped, Effect.provide(runtime))), it),
130
128
  flakyTest,
131
129
  layer(nestedLayer, options) {
132
130
  return layer(Layer.provideMerge(nestedLayer, withTestEnv), {
@@ -137,24 +135,22 @@ export const layer = (layer_, options) => (...args) => {
137
135
  }
138
136
  });
139
137
  if (args.length === 1) {
140
- V.beforeAll(() => runPromise()(Effect.asVoid(runtimeEffect)), options?.timeout ? Duration.toMillis(options.timeout) : undefined);
141
- V.afterAll(() => runPromise()(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(options.timeout) : undefined);
142
- return args[0](makeIt(defaultApi));
138
+ V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromDurationInputUnsafe(options.timeout)) : undefined);
139
+ V.afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromDurationInputUnsafe(options.timeout)) : undefined);
140
+ return args[0](makeIt(V.it));
143
141
  }
144
142
  return V.describe(args[0], () => {
145
- V.beforeAll(() => runPromise()(Effect.asVoid(runtimeEffect)), options?.timeout ? Duration.toMillis(options.timeout) : undefined);
146
- V.afterAll(() => runPromise()(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(options.timeout) : undefined);
147
- return args[1](makeIt(defaultApi));
143
+ V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromDurationInputUnsafe(options.timeout)) : undefined);
144
+ V.afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromDurationInputUnsafe(options.timeout)) : undefined);
145
+ return args[1](makeIt(V.it));
148
146
  });
149
147
  };
150
148
  /** @internal */
151
- export const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(Effect.catchAllDefect(self, Effect.fail), Effect.retry(pipe(Schedule.recurs(10), Schedule.compose(Schedule.elapsed), Schedule.whileOutput(Duration.lessThanOrEqualTo(timeout)))), Effect.orDie);
149
+ export const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(self, Effect.scoped, Effect.sandbox, Effect.retry(pipe(Schedule.recurs(10), Schedule.while(_ => Effect.succeed(Duration.isLessThanOrEqualTo(Duration.fromDurationInputUnsafe(_.elapsed), Duration.fromDurationInputUnsafe(timeout)))))), Effect.orDie);
152
150
  /** @internal */
153
151
  export const makeMethods = it => Object.assign(it, {
154
- effect: makeTester(Effect.provide(TestEnv), it),
155
- scoped: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),
156
- live: makeTester(identity, it),
157
- scopedLive: makeTester(Effect.scoped, it),
152
+ effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),
153
+ live: makeTester(Effect.scoped, it),
158
154
  flakyTest,
159
155
  layer,
160
156
  prop
@@ -164,14 +160,8 @@ export const {
164
160
  /** @internal */
165
161
  effect,
166
162
  /** @internal */
167
- live,
168
- /** @internal */
169
- scoped,
170
- /** @internal */
171
- scopedLive
172
- } = /*#__PURE__*/makeMethods(defaultApi);
163
+ live
164
+ } = /*#__PURE__*/makeMethods(V.it);
173
165
  /** @internal */
174
- export const describeWrapped = (name, f) => V.describe(name, it => f(makeMethods(Object.assign(it, {
175
- scopedFixtures: it.scoped
176
- }))));
166
+ export const describeWrapped = (name, f) => V.describe(name, it => f(makeMethods(it)));
177
167
  //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","names":["Cause","Duration","Effect","Exit","flow","pipe","Layer","isObject","Schedule","Schema","Scope","fc","TestClock","TestConsole","V","runPromise","fnUntraced","effect","_ctx","exit","isFailure","errors","prettyErrors","cause","i","length","logError","_","ctx","signal","runTest","TestEnv","mergeAll","layer","addEqualityTesters","expect","testOptions","timeout","makeTester","mapEffect","it","run","args","self","suspend","f","name","skip","skipIf","condition","runIf","only","each","cases","for","fails","prop","arbitraries","Array","isArray","arbs","map","arbitrary","isSchema","toArbitrary","assert","asyncProperty","as","fastCheck","record","Object","keys","reduce","result","key","arb","assign","Error","property","layer_","options","excludeTestServices","withTestEnv","provideMerge","memoMap","runSync","makeMemoMap","scope","make","contextEffect","buildWithMemoMap","orDie","cached","makeIt","flatMap","context","scoped","provide","flakyTest","nestedLayer","beforeAll","asVoid","toMillis","fromDurationInputUnsafe","undefined","afterAll","close","void","describe","seconds","sandbox","retry","recurs","while","succeed","isLessThanOrEqualTo","elapsed","makeMethods","live","describeWrapped"],"sources":["../../src/internal/internal.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,SAASC,IAAI,EAAEC,IAAI,QAAQ,iBAAiB;AAC5C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,kBAAkB;AAC3C,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,EAAE,MAAM,0BAA0B;AAC9C,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,WAAW,MAAM,4BAA4B;AACzD,OAAO,KAAKC,CAAC,MAAM,QAAQ;AAG3B,MAAMC,UAAU,gBAGEb,MAAM,CAACc,UAAU,CAAC,WAAgBC,MAA2B,EAAEC,IAAyB;EACxG,MAAMC,IAAI,GAAG,OAAOjB,MAAM,CAACiB,IAAI,CAACF,MAAM,CAAC;EACvC,IAAId,IAAI,CAACiB,SAAS,CAACD,IAAI,CAAC,EAAE;IACxB,MAAME,MAAM,GAAGrB,KAAK,CAACsB,YAAY,CAACH,IAAI,CAACI,KAAK,CAAC;IAC7C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,MAAM,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;MACtC,OAAOtB,MAAM,CAACwB,QAAQ,CAACL,MAAM,CAACG,CAAC,CAAC,CAAC;IACnC;EACF;EACA,OAAO,OAAOL,IAAI;AACpB,CAAC,E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AAE,CAAC,EACnBxG,QAAQ,CAACyG,KAAK,CAAEtF,CAAC,IACfzB,MAAM,CAACgH,OAAO,CAACjH,QAAQ,CAACkH,mBAAmB,CACzClH,QAAQ,CAACsG,uBAAuB,CAAC5E,CAAC,CAACyF,OAAO,CAAC,EAC3CnH,QAAQ,CAACsG,uBAAuB,CAAClE,OAAO,CAAC,CAC1C,CAAC,CACH,CACF,CACF,EACDnC,MAAM,CAACyF,KAAK,CACb;AAEH;AACA,OAAO,MAAM0B,WAAW,GAAI7E,EAAa,IACvC8B,MAAM,CAACM,MAAM,CAACpC,EAAE,EAAE;EAChBvB,MAAM,EAAEqB,UAAU,CAAclC,IAAI,CAACF,MAAM,CAAC8F,MAAM,EAAE9F,MAAM,CAAC+F,OAAO,CAAClE,OAAO,CAAC,CAAC,EAAES,EAAE,CAAC;EACjF8E,IAAI,EAAEhF,UAAU,CAAcpC,MAAM,CAAC8F,MAAM,EAAExD,EAAE,CAAC;EAChD0D,SAAS;EACTjE,KAAK;EACLuB;CACD,CAAC;AAEJ;AACA,OAAO,MAAM;EACX;EACAvC,MAAM;EACN;EACAqG;AAAI,CACL,gBAAGD,WAAW,CAACvG,CAAC,CAAC0B,EAAE,CAAC;AAErB;AACA,OAAO,MAAM+E,eAAe,GAAGA,CAACzE,IAAY,EAAED,CAAsC,KAClF/B,CAAC,CAAC8F,QAAQ,CAAC9D,IAAI,EAAGN,EAAE,IAAKK,CAAC,CAACwE,WAAW,CAAC7E,EAAE,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -1,122 +1,134 @@
1
1
  /**
2
- * @since 0.21.0
2
+ * @since 4.0.0
3
3
  */
4
4
  import type * as Cause from "effect/Cause";
5
- import * as Either from "effect/Either";
6
5
  import * as Exit from "effect/Exit";
7
6
  import * as Option from "effect/Option";
7
+ import * as Result from "effect/Result";
8
8
  /**
9
9
  * Throws an `AssertionError` with the provided error message.
10
10
  *
11
- * @since 0.21.0
11
+ * @since 4.0.0
12
12
  */
13
13
  export declare function fail(message: string): void;
14
14
  /**
15
15
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
16
16
  *
17
- * @since 0.21.0
17
+ * @since 4.0.0
18
18
  */
19
19
  export declare function deepStrictEqual<A>(actual: A, expected: A, message?: string, ..._: Array<never>): void;
20
20
  /**
21
21
  * Asserts that `actual` is not equal to `expected` using the `Equal.equals` trait.
22
22
  *
23
- * @since 0.21.0
23
+ * @since 4.0.0
24
24
  */
25
25
  export declare function notDeepStrictEqual<A>(actual: A, expected: A, message?: string, ..._: Array<never>): void;
26
26
  /**
27
27
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
28
28
  *
29
- * @since 0.21.0
29
+ * @since 4.0.0
30
30
  */
31
31
  export declare function strictEqual<A>(actual: A, expected: A, message?: string, ..._: Array<never>): void;
32
32
  /**
33
33
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
34
34
  *
35
- * @since 0.21.0
35
+ * @since 4.0.0
36
36
  */
37
37
  export declare function assertEquals<A>(actual: A, expected: A, message?: string, ..._: Array<never>): void;
38
38
  /**
39
39
  * Asserts that `thunk` does not throw an error.
40
40
  *
41
- * @since 0.21.0
41
+ * @since 4.0.0
42
42
  */
43
43
  export declare function doesNotThrow(thunk: () => void, message?: string, ..._: Array<never>): void;
44
44
  /**
45
45
  * Asserts that `value` is an instance of `constructor`.
46
46
  *
47
- * @since 0.21.0
47
+ * @since 4.0.0
48
48
  */
49
49
  export declare function assertInstanceOf<C extends abstract new (...args: any) => any>(value: unknown, constructor: C, message?: string, ..._: Array<never>): asserts value is InstanceType<C>;
50
50
  /**
51
51
  * Asserts that `self` is `true`.
52
52
  *
53
- * @since 0.21.0
53
+ * @since 4.0.0
54
54
  */
55
55
  export declare function assertTrue(self: unknown, message?: string, ..._: Array<never>): asserts self;
56
56
  /**
57
57
  * Asserts that `self` is `false`.
58
58
  *
59
- * @since 0.21.0
59
+ * @since 4.0.0
60
60
  */
61
61
  export declare function assertFalse(self: boolean, message?: string, ..._: Array<never>): void;
62
62
  /**
63
63
  * Asserts that `actual` includes `expected`.
64
64
  *
65
- * @since 0.21.0
65
+ * @since 4.0.0
66
66
  */
67
67
  export declare function assertInclude(actual: string | undefined, expected: string, ..._: Array<never>): void;
68
68
  /**
69
- * Asserts that `actual` matches `regexp`.
69
+ * Asserts that `actual` matches `regExp`.
70
70
  *
71
- * @since 0.21.0
71
+ * @since 4.0.0
72
72
  */
73
- export declare function assertMatch(actual: string, regexp: RegExp, ..._: Array<never>): void;
73
+ export declare function assertMatch(actual: string, regExp: RegExp, ..._: Array<never>): void;
74
74
  /**
75
75
  * Asserts that `thunk` throws an error.
76
76
  *
77
- * @since 0.21.0
77
+ * @since 4.0.0
78
78
  */
79
79
  export declare function throws(thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never>): void;
80
80
  /**
81
81
  * Asserts that `thunk` throws an error.
82
82
  *
83
- * @since 0.21.0
83
+ * @since 4.0.0
84
84
  */
85
85
  export declare function throwsAsync(thunk: () => Promise<void>, error?: Error | ((u: unknown) => undefined), ..._: Array<never>): Promise<void>;
86
86
  /**
87
87
  * Asserts that `option` is `None`.
88
88
  *
89
- * @since 0.21.0
89
+ * @since 4.0.0
90
90
  */
91
91
  export declare function assertNone<A>(option: Option.Option<A>, ..._: Array<never>): asserts option is Option.None<never>;
92
+ /**
93
+ * Asserts that `a` is not `undefined`.
94
+ *
95
+ * @since 4.0.0
96
+ */
97
+ export declare function assertDefined<A>(a: A | undefined, ..._: Array<never>): asserts a is Exclude<A, undefined>;
98
+ /**
99
+ * Asserts that `a` is `undefined`.
100
+ *
101
+ * @since 4.0.0
102
+ */
103
+ export declare function assertUndefined<A>(a: A | undefined, ..._: Array<never>): asserts a is undefined;
92
104
  /**
93
105
  * Asserts that `option` is `Some`.
94
106
  *
95
- * @since 0.21.0
107
+ * @since 4.0.0
96
108
  */
97
109
  export declare function assertSome<A>(option: Option.Option<A>, expected: A, ..._: Array<never>): asserts option is Option.Some<A>;
98
110
  /**
99
- * Asserts that `either` is `Left`.
111
+ * Asserts that `result` is `Success`.
100
112
  *
101
- * @since 0.21.0
113
+ * @since 4.0.0
102
114
  */
103
- export declare function assertLeft<R, L>(either: Either.Either<R, L>, expected: L, ..._: Array<never>): asserts either is Either.Left<L, never>;
115
+ export declare function assertSuccess<A, E>(result: Result.Result<A, E>, expected: A, ..._: Array<never>): asserts result is Result.Success<A, never>;
104
116
  /**
105
- * Asserts that `either` is `Right`.
117
+ * Asserts that `result` is `Failure`.
106
118
  *
107
- * @since 0.21.0
119
+ * @since 4.0.0
108
120
  */
109
- export declare function assertRight<R, L>(either: Either.Either<R, L>, expected: R, ..._: Array<never>): asserts either is Either.Right<never, R>;
121
+ export declare function assertFailure<A, E>(result: Result.Result<A, E>, expected: E, ..._: Array<never>): asserts result is Result.Failure<never, E>;
110
122
  /**
111
123
  * Asserts that `exit` is a failure.
112
124
  *
113
- * @since 0.21.0
125
+ * @since 4.0.0
114
126
  */
115
- export declare function assertFailure<A, E>(exit: Exit.Exit<A, E>, expected: Cause.Cause<E>, ..._: Array<never>): asserts exit is Exit.Failure<never, E>;
127
+ export declare function assertExitFailure<A, E>(exit: Exit.Exit<A, E>, expected: Cause.Cause<E>, ..._: Array<never>): asserts exit is Exit.Failure<never, E>;
116
128
  /**
117
129
  * Asserts that `exit` is a success.
118
130
  *
119
- * @since 0.21.0
131
+ * @since 4.0.0
120
132
  */
121
- export declare function assertSuccess<A, E>(exit: Exit.Exit<A, E>, expected: A, ..._: Array<never>): asserts exit is Exit.Success<A, never>;
133
+ export declare function assertExitSuccess<A, E>(exit: Exit.Exit<A, E>, expected: A, ..._: Array<never>): asserts exit is Exit.Success<A, never>;
122
134
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,OAAO,KAA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C,GACjB,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAE5C;AAMD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACpC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EACrB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EACxB,GAAG,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GACjB,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAExC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACpC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EACrB,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GACjB,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAExC"}
@@ -1,8 +1,8 @@
1
- import * as Either from "effect/Either";
2
1
  import * as Equal from "effect/Equal";
3
2
  import * as Exit from "effect/Exit";
4
3
  import * as Option from "effect/Option";
5
4
  import * as Predicate from "effect/Predicate";
5
+ import * as Result from "effect/Result";
6
6
  import * as assert from "node:assert";
7
7
  import { assert as vassert } from "vitest";
8
8
  // ----------------------------
@@ -11,7 +11,7 @@ import { assert as vassert } from "vitest";
11
11
  /**
12
12
  * Throws an `AssertionError` with the provided error message.
13
13
  *
14
- * @since 0.21.0
14
+ * @since 4.0.0
15
15
  */
16
16
  export function fail(message) {
17
17
  assert.fail(message);
@@ -19,7 +19,7 @@ export function fail(message) {
19
19
  /**
20
20
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
21
21
  *
22
- * @since 0.21.0
22
+ * @since 4.0.0
23
23
  */
24
24
  export function deepStrictEqual(actual, expected, message, ..._) {
25
25
  assert.deepStrictEqual(actual, expected, message);
@@ -27,7 +27,7 @@ export function deepStrictEqual(actual, expected, message, ..._) {
27
27
  /**
28
28
  * Asserts that `actual` is not equal to `expected` using the `Equal.equals` trait.
29
29
  *
30
- * @since 0.21.0
30
+ * @since 4.0.0
31
31
  */
32
32
  export function notDeepStrictEqual(actual, expected, message, ..._) {
33
33
  assert.notDeepStrictEqual(actual, expected, message);
@@ -35,7 +35,7 @@ export function notDeepStrictEqual(actual, expected, message, ..._) {
35
35
  /**
36
36
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
37
37
  *
38
- * @since 0.21.0
38
+ * @since 4.0.0
39
39
  */
40
40
  export function strictEqual(actual, expected, message, ..._) {
41
41
  assert.strictEqual(actual, expected, message);
@@ -43,7 +43,7 @@ export function strictEqual(actual, expected, message, ..._) {
43
43
  /**
44
44
  * Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
45
45
  *
46
- * @since 0.21.0
46
+ * @since 4.0.0
47
47
  */
48
48
  export function assertEquals(actual, expected, message, ..._) {
49
49
  if (!Equal.equals(actual, expected)) {
@@ -54,7 +54,7 @@ export function assertEquals(actual, expected, message, ..._) {
54
54
  /**
55
55
  * Asserts that `thunk` does not throw an error.
56
56
  *
57
- * @since 0.21.0
57
+ * @since 4.0.0
58
58
  */
59
59
  export function doesNotThrow(thunk, message, ..._) {
60
60
  assert.doesNotThrow(thunk, message);
@@ -65,16 +65,15 @@ export function doesNotThrow(thunk, message, ..._) {
65
65
  /**
66
66
  * Asserts that `value` is an instance of `constructor`.
67
67
  *
68
- * @since 0.21.0
68
+ * @since 4.0.0
69
69
  */
70
70
  export function assertInstanceOf(value, constructor, message, ..._) {
71
- // @ts-ignore
72
71
  vassert.instanceOf(value, constructor, message);
73
72
  }
74
73
  /**
75
74
  * Asserts that `self` is `true`.
76
75
  *
77
- * @since 0.21.0
76
+ * @since 4.0.0
78
77
  */
79
78
  export function assertTrue(self, message, ..._) {
80
79
  strictEqual(self, true, message);
@@ -82,7 +81,7 @@ export function assertTrue(self, message, ..._) {
82
81
  /**
83
82
  * Asserts that `self` is `false`.
84
83
  *
85
- * @since 0.21.0
84
+ * @since 4.0.0
86
85
  */
87
86
  export function assertFalse(self, message, ..._) {
88
87
  strictEqual(self, false, message);
@@ -90,29 +89,29 @@ export function assertFalse(self, message, ..._) {
90
89
  /**
91
90
  * Asserts that `actual` includes `expected`.
92
91
  *
93
- * @since 0.21.0
92
+ * @since 4.0.0
94
93
  */
95
94
  export function assertInclude(actual, expected, ..._) {
96
- if (Predicate.isString(expected)) {
95
+ if (typeof expected === "string") {
97
96
  if (!actual?.includes(expected)) {
98
97
  fail(`Expected\n\n${actual}\n\nto include\n\n${expected}`);
99
98
  }
100
99
  }
101
100
  }
102
101
  /**
103
- * Asserts that `actual` matches `regexp`.
102
+ * Asserts that `actual` matches `regExp`.
104
103
  *
105
- * @since 0.21.0
104
+ * @since 4.0.0
106
105
  */
107
- export function assertMatch(actual, regexp, ..._) {
108
- if (!regexp.test(actual)) {
109
- fail(`Expected\n\n${actual}\n\nto match\n\n${regexp}`);
106
+ export function assertMatch(actual, regExp, ..._) {
107
+ if (!regExp.test(actual)) {
108
+ fail(`Expected\n\n${actual}\n\nto match\n\n${regExp}`);
110
109
  }
111
110
  }
112
111
  /**
113
112
  * Asserts that `thunk` throws an error.
114
113
  *
115
- * @since 0.21.0
114
+ * @since 4.0.0
116
115
  */
117
116
  export function throws(thunk, error, ..._) {
118
117
  try {
@@ -131,7 +130,7 @@ export function throws(thunk, error, ..._) {
131
130
  /**
132
131
  * Asserts that `thunk` throws an error.
133
132
  *
134
- * @since 0.21.0
133
+ * @since 4.0.0
135
134
  */
136
135
  export async function throwsAsync(thunk, error, ..._) {
137
136
  try {
@@ -153,37 +152,57 @@ export async function throwsAsync(thunk, error, ..._) {
153
152
  /**
154
153
  * Asserts that `option` is `None`.
155
154
  *
156
- * @since 0.21.0
155
+ * @since 4.0.0
157
156
  */
158
157
  export function assertNone(option, ..._) {
159
158
  deepStrictEqual(option, Option.none());
160
159
  }
160
+ /**
161
+ * Asserts that `a` is not `undefined`.
162
+ *
163
+ * @since 4.0.0
164
+ */
165
+ export function assertDefined(a, ..._) {
166
+ if (a === undefined) {
167
+ fail("Expected value to be defined");
168
+ }
169
+ }
170
+ /**
171
+ * Asserts that `a` is `undefined`.
172
+ *
173
+ * @since 4.0.0
174
+ */
175
+ export function assertUndefined(a, ..._) {
176
+ if (a !== undefined) {
177
+ fail("Expected value to be undefined");
178
+ }
179
+ }
161
180
  /**
162
181
  * Asserts that `option` is `Some`.
163
182
  *
164
- * @since 0.21.0
183
+ * @since 4.0.0
165
184
  */
166
185
  export function assertSome(option, expected, ..._) {
167
186
  deepStrictEqual(option, Option.some(expected));
168
187
  }
169
188
  // ----------------------------
170
- // Either
189
+ // Result
171
190
  // ----------------------------
172
191
  /**
173
- * Asserts that `either` is `Left`.
192
+ * Asserts that `result` is `Success`.
174
193
  *
175
- * @since 0.21.0
194
+ * @since 4.0.0
176
195
  */
177
- export function assertLeft(either, expected, ..._) {
178
- deepStrictEqual(either, Either.left(expected));
196
+ export function assertSuccess(result, expected, ..._) {
197
+ deepStrictEqual(result, Result.succeed(expected));
179
198
  }
180
199
  /**
181
- * Asserts that `either` is `Right`.
200
+ * Asserts that `result` is `Failure`.
182
201
  *
183
- * @since 0.21.0
202
+ * @since 4.0.0
184
203
  */
185
- export function assertRight(either, expected, ..._) {
186
- deepStrictEqual(either, Either.right(expected));
204
+ export function assertFailure(result, expected, ..._) {
205
+ deepStrictEqual(result, Result.fail(expected));
187
206
  }
188
207
  // ----------------------------
189
208
  // Exit
@@ -191,17 +210,17 @@ export function assertRight(either, expected, ..._) {
191
210
  /**
192
211
  * Asserts that `exit` is a failure.
193
212
  *
194
- * @since 0.21.0
213
+ * @since 4.0.0
195
214
  */
196
- export function assertFailure(exit, expected, ..._) {
215
+ export function assertExitFailure(exit, expected, ..._) {
197
216
  deepStrictEqual(exit, Exit.failCause(expected));
198
217
  }
199
218
  /**
200
219
  * Asserts that `exit` is a success.
201
220
  *
202
- * @since 0.21.0
221
+ * @since 4.0.0
203
222
  */
204
- export function assertSuccess(exit, expected, ..._) {
223
+ export function assertExitSuccess(exit, expected, ..._) {
205
224
  deepStrictEqual(exit, Exit.succeed(expected));
206
225
  }
207
226
  //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["Equal","Exit","Option","Predicate","Result","assert","vassert","fail","message","deepStrictEqual","actual","expected","_","notDeepStrictEqual","strictEqual","assertEquals","equals","doesNotThrow","thunk","assertInstanceOf","value","constructor","instanceOf","assertTrue","self","assertFalse","assertInclude","includes","assertMatch","regExp","test","throws","error","e","undefined","isFunction","throwsAsync","assertNone","option","none","assertDefined","a","assertUndefined","assertSome","some","assertSuccess","result","succeed","assertFailure","assertExitFailure","exit","failCause","assertExitSuccess"],"sources":["../src/utils.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,SAASA,MAAM,IAAIC,OAAO,QAAQ,QAAQ;AAE1C;AACA;AACA;AAEA;;;;;AAKA,OAAM,SAAUC,IAAIA,CAACC,OAAe;EAClCH,MAAM,CAACE,IAAI,CAACC,OAAO,CAAC;AACtB;AAEA;;;;;AAKA,OAAM,SAAUC,eAAeA,CAAIC,MAAS,EAAEC,QAAW,EAAEH,OAAgB,EAAE,GAAGI,CAAe;EAC7FP,MAAM,CAACI,eAAe,CAACC,MAAM,EAAEC,QAAQ,EAAEH,OAAO,CAAC;AACnD;AAEA;;;;;AAKA,OAAM,SAAUK,kBAAkBA,CAAIH,MAAS,EAAEC,QAAW,EAA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