@logixjs/test 0.0.1 → 1.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/LICENSE +201 -0
- package/dist/Act-65bCRtuC.d.cts +31 -0
- package/dist/Act-65bCRtuC.d.ts +31 -0
- package/dist/Act.cjs +91 -0
- package/dist/Act.d.cts +3 -0
- package/dist/Act.d.ts +3 -0
- package/dist/Act.js +15 -0
- package/dist/{Assertions-uDVCBadW.d.cts → Assertions-CzVzJ0dQ.d.cts} +1 -1
- package/dist/{Assertions-OpNAhiI_.d.ts → Assertions-D2zfasOD.d.ts} +1 -1
- package/dist/Assertions.cjs +3 -2
- package/dist/Assertions.d.cts +3 -2
- package/dist/Assertions.d.ts +3 -2
- package/dist/Assertions.js +2 -2
- package/dist/{TestProgram-BLXiWhJQ.d.cts → TestProgram-BNm-06UK.d.cts} +4 -3
- package/dist/{TestProgram-CPvVAbfI.d.cts → TestProgram-DHhYdhOm.d.cts} +1 -1
- package/dist/{TestProgram-X35n_2Js.d.ts → TestProgram-DolBjSUH.d.ts} +4 -3
- package/dist/{TestProgram-DJAm0dIS.d.ts → TestProgram-zI8wr33R.d.ts} +1 -1
- package/dist/TestProgram.cjs +28 -31
- package/dist/TestProgram.d.cts +3 -2
- package/dist/TestProgram.d.ts +3 -2
- package/dist/TestProgram.js +3 -3
- package/dist/TestRuntime.cjs +2 -1
- package/dist/TestRuntime.js +2 -2
- package/dist/{Vitest-BiBMIx3C.d.cts → Vitest-2U7CpZsz.d.cts} +1 -1
- package/dist/{Vitest-BXBtxem-.d.ts → Vitest-Dr3jUgWl.d.ts} +1 -1
- package/dist/Vitest.cjs +30 -32
- package/dist/Vitest.d.cts +4 -3
- package/dist/Vitest.d.ts +4 -3
- package/dist/Vitest.js +4 -4
- package/dist/{chunk-CZJ37XWT.js → chunk-3XOKB7L4.js} +25 -29
- package/dist/{chunk-DU6VSL4D.js → chunk-5I2BFXGD.js} +3 -2
- package/dist/chunk-AJNVZ6GR.js +66 -0
- package/dist/{chunk-WVD5DTP4.js → chunk-CRWKRQEB.js} +1 -1
- package/dist/{chunk-5XFEOVH5.js → chunk-JX3RZZWB.js} +1 -1
- package/dist/{chunk-DKT5EFOF.js → chunk-OO3UZI3U.js} +3 -2
- package/dist/{chunk-42QGM623.js → chunk-PPQRMDUV.js} +1 -1
- package/dist/{chunk-TDYES47J.js → chunk-SP6DKYGN.js} +2 -2
- package/dist/index.cjs +86 -32
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +11 -7
- package/dist/{waitUntil-CjpwZxCu.d.cts → waitUntil-CZQDLJ7j.d.cts} +3 -2
- package/dist/{waitUntil-CjpwZxCu.d.ts → waitUntil-CZQDLJ7j.d.ts} +3 -2
- package/package.json +12 -6
package/dist/TestProgram.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-
|
|
1
|
+
export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-DolBjSUH.js';
|
|
2
2
|
import 'effect';
|
|
3
3
|
import '@logixjs/core';
|
|
4
4
|
import '@logixjs/core/Runtime';
|
|
5
5
|
import './ExecutionResult-BRC-Jzsv.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'effect/testing';
|
|
7
|
+
import './waitUntil-CZQDLJ7j.js';
|
package/dist/TestProgram.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-JX3RZZWB.js";
|
|
2
2
|
import {
|
|
3
3
|
runProgram
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-3XOKB7L4.js";
|
|
5
|
+
import "./chunk-5I2BFXGD.js";
|
|
6
6
|
import "./chunk-RG24KSEB.js";
|
|
7
7
|
import "./chunk-FOYMJMJR.js";
|
|
8
8
|
export {
|
package/dist/TestRuntime.cjs
CHANGED
|
@@ -26,8 +26,9 @@ module.exports = __toCommonJS(TestRuntime_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/internal/runtime/runTest.ts
|
|
28
28
|
var import_effect = require("effect");
|
|
29
|
+
var import_testing = require("effect/testing");
|
|
29
30
|
var runTest = (effect) => {
|
|
30
|
-
const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(
|
|
31
|
+
const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_testing.TestClock.layer()));
|
|
31
32
|
return import_effect.Effect.runPromise(program);
|
|
32
33
|
};
|
|
33
34
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/TestRuntime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import * as Logix from '@logixjs/core';
|
|
3
3
|
import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.cjs';
|
|
4
|
-
import { T as TestApi, a as TestProgramOptions } from './TestProgram-
|
|
4
|
+
import { T as TestApi, a as TestProgramOptions } from './TestProgram-BNm-06UK.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Sugar: defines a program test based on `TestProgram.runProgram`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import * as Logix from '@logixjs/core';
|
|
3
3
|
import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.js';
|
|
4
|
-
import { T as TestApi, a as TestProgramOptions } from './TestProgram-
|
|
4
|
+
import { T as TestApi, a as TestProgramOptions } from './TestProgram-DolBjSUH.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Sugar: defines a program test based on `TestProgram.runProgram`.
|
package/dist/Vitest.cjs
CHANGED
|
@@ -3117,13 +3117,15 @@ var expectNoError = (result) => {
|
|
|
3117
3117
|
|
|
3118
3118
|
// src/internal/runtime/runTest.ts
|
|
3119
3119
|
var import_effect = require("effect");
|
|
3120
|
+
var import_testing = require("effect/testing");
|
|
3120
3121
|
var runTest = (effect) => {
|
|
3121
|
-
const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(
|
|
3122
|
+
const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_testing.TestClock.layer()));
|
|
3122
3123
|
return import_effect.Effect.runPromise(program);
|
|
3123
3124
|
};
|
|
3124
3125
|
|
|
3125
3126
|
// src/internal/api/TestProgram.ts
|
|
3126
3127
|
var import_effect4 = require("effect");
|
|
3128
|
+
var import_testing3 = require("effect/testing");
|
|
3127
3129
|
var Logix = __toESM(require("@logixjs/core"), 1);
|
|
3128
3130
|
|
|
3129
3131
|
// src/internal/utils/assertions.ts
|
|
@@ -3162,6 +3164,7 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
|
|
|
3162
3164
|
|
|
3163
3165
|
// src/internal/utils/waitUntil.ts
|
|
3164
3166
|
var import_effect3 = require("effect");
|
|
3167
|
+
var import_testing2 = require("effect/testing");
|
|
3165
3168
|
var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* () {
|
|
3166
3169
|
const maxAttempts = options.maxAttempts ?? 20;
|
|
3167
3170
|
const step = options.step ?? "10 millis";
|
|
@@ -3172,8 +3175,8 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
|
|
|
3172
3175
|
return result.value;
|
|
3173
3176
|
}
|
|
3174
3177
|
lastError = result.cause;
|
|
3175
|
-
yield*
|
|
3176
|
-
yield* import_effect3.Effect.yieldNow
|
|
3178
|
+
yield* import_testing2.TestClock.adjust(step);
|
|
3179
|
+
yield* import_effect3.Effect.yieldNow;
|
|
3177
3180
|
}
|
|
3178
3181
|
return yield* import_effect3.Effect.fail(lastError);
|
|
3179
3182
|
});
|
|
@@ -3182,7 +3185,7 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
|
|
|
3182
3185
|
var defaultOptions = (options) => {
|
|
3183
3186
|
const base = options ?? {};
|
|
3184
3187
|
const userLayer = base.layer ?? import_effect4.Layer.empty;
|
|
3185
|
-
const layer = import_effect4.Layer.mergeAll(
|
|
3188
|
+
const layer = import_effect4.Layer.mergeAll(import_testing3.TestClock.layer(), userLayer);
|
|
3186
3189
|
return {
|
|
3187
3190
|
...base,
|
|
3188
3191
|
layer,
|
|
@@ -3214,7 +3217,7 @@ var makeTestApi = (ctx, actionsRef) => {
|
|
|
3214
3217
|
return {
|
|
3215
3218
|
ctx,
|
|
3216
3219
|
dispatch: ctx.module.dispatch,
|
|
3217
|
-
advance: (duration) =>
|
|
3220
|
+
advance: (duration) => import_testing3.TestClock.adjust(duration).pipe(import_effect4.Effect.asVoid),
|
|
3218
3221
|
assert: {
|
|
3219
3222
|
state: assertStateEffect,
|
|
3220
3223
|
signal: assertSignalEffect
|
|
@@ -3230,7 +3233,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
|
|
|
3230
3233
|
yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
|
|
3231
3234
|
yield* import_effect4.Ref.update(actionsRef, import_effect4.Chunk.append(action));
|
|
3232
3235
|
})
|
|
3233
|
-
).pipe(import_effect4.Effect.
|
|
3236
|
+
).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
|
|
3234
3237
|
yield* import_effect4.Stream.runForEach(
|
|
3235
3238
|
ctx.module.changes((s) => s),
|
|
3236
3239
|
(state) => import_effect4.Effect.gen(function* () {
|
|
@@ -3238,10 +3241,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
|
|
|
3238
3241
|
const event = { _tag: "State", state, timestamp };
|
|
3239
3242
|
yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
|
|
3240
3243
|
})
|
|
3241
|
-
).pipe(import_effect4.Effect.
|
|
3242
|
-
yield*
|
|
3243
|
-
yield* import_effect4.Effect.yieldNow
|
|
3244
|
+
).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
|
|
3245
|
+
yield* import_testing3.TestClock.adjust(1);
|
|
3246
|
+
yield* import_effect4.Effect.yieldNow;
|
|
3244
3247
|
});
|
|
3248
|
+
var runInProgramScope = (ctx, effect) => import_effect4.Effect.tryPromise({
|
|
3249
|
+
try: () => ctx.runtime.runPromise(import_effect4.Effect.provideService(effect, import_effect4.Scope.Scope, ctx.scope)),
|
|
3250
|
+
catch: (e) => e
|
|
3251
|
+
}).pipe(import_effect4.Effect.orDie);
|
|
3245
3252
|
var runProgram = (program, body, options) => import_effect4.Effect.gen(function* () {
|
|
3246
3253
|
const traceRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
|
|
3247
3254
|
const actionsRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
|
|
@@ -3262,31 +3269,22 @@ var runProgram = (program, body, options) => import_effect4.Effect.gen(function*
|
|
|
3262
3269
|
}
|
|
3263
3270
|
};
|
|
3264
3271
|
const resolved = defaultOptions(options);
|
|
3265
|
-
const ctx = yield* import_effect4.Effect.
|
|
3266
|
-
Logix.Runtime.openProgram(program, resolved)
|
|
3272
|
+
const ctx = yield* import_effect4.Effect.provideService(
|
|
3273
|
+
Logix.Runtime.openProgram(program, resolved),
|
|
3274
|
+
Logix.Debug.internal.currentDebugSinks,
|
|
3275
|
+
[debugSink]
|
|
3267
3276
|
);
|
|
3268
|
-
yield*
|
|
3269
|
-
try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
|
|
3270
|
-
catch: (e) => e
|
|
3271
|
-
}).pipe(import_effect4.Effect.orDie);
|
|
3277
|
+
yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
|
|
3272
3278
|
const api = makeTestApi(ctx, actionsRef);
|
|
3273
|
-
yield*
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
})
|
|
3283
|
-
),
|
|
3284
|
-
catch: (e) => e
|
|
3285
|
-
}).pipe(import_effect4.Effect.orDie);
|
|
3286
|
-
const finalState = yield* import_effect4.Effect.tryPromise({
|
|
3287
|
-
try: () => ctx.runtime.runPromise(ctx.module.getState),
|
|
3288
|
-
catch: (e) => e
|
|
3289
|
-
}).pipe(import_effect4.Effect.orDie);
|
|
3279
|
+
yield* runInProgramScope(ctx, body(api));
|
|
3280
|
+
yield* runInProgramScope(
|
|
3281
|
+
ctx,
|
|
3282
|
+
import_effect4.Effect.gen(function* () {
|
|
3283
|
+
yield* import_testing3.TestClock.adjust(1);
|
|
3284
|
+
yield* import_effect4.Effect.yieldNow;
|
|
3285
|
+
})
|
|
3286
|
+
);
|
|
3287
|
+
const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
|
|
3290
3288
|
const actionsChunk = yield* import_effect4.Ref.get(actionsRef);
|
|
3291
3289
|
const traceChunk = yield* import_effect4.Ref.get(traceRef);
|
|
3292
3290
|
return make(
|
package/dist/Vitest.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { i as itProgram, a as itProgramResult } from './Vitest-
|
|
1
|
+
export { i as itProgram, a as itProgramResult } from './Vitest-2U7CpZsz.cjs';
|
|
2
2
|
import 'effect';
|
|
3
3
|
import '@logixjs/core';
|
|
4
4
|
import './ExecutionResult-BRC-Jzsv.cjs';
|
|
5
|
-
import './TestProgram-
|
|
5
|
+
import './TestProgram-BNm-06UK.cjs';
|
|
6
6
|
import '@logixjs/core/Runtime';
|
|
7
|
-
import '
|
|
7
|
+
import 'effect/testing';
|
|
8
|
+
import './waitUntil-CZQDLJ7j.cjs';
|
package/dist/Vitest.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { i as itProgram, a as itProgramResult } from './Vitest-
|
|
1
|
+
export { i as itProgram, a as itProgramResult } from './Vitest-Dr3jUgWl.js';
|
|
2
2
|
import 'effect';
|
|
3
3
|
import '@logixjs/core';
|
|
4
4
|
import './ExecutionResult-BRC-Jzsv.js';
|
|
5
|
-
import './TestProgram-
|
|
5
|
+
import './TestProgram-DolBjSUH.js';
|
|
6
6
|
import '@logixjs/core/Runtime';
|
|
7
|
-
import '
|
|
7
|
+
import 'effect/testing';
|
|
8
|
+
import './waitUntil-CZQDLJ7j.js';
|
package/dist/Vitest.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
itProgram,
|
|
3
3
|
itProgramResult
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-SP6DKYGN.js";
|
|
5
|
+
import "./chunk-3XOKB7L4.js";
|
|
6
|
+
import "./chunk-5I2BFXGD.js";
|
|
7
7
|
import "./chunk-RG24KSEB.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-OO3UZI3U.js";
|
|
9
9
|
import "./chunk-FOYMJMJR.js";
|
|
10
10
|
export {
|
|
11
11
|
itProgram,
|
|
@@ -2,18 +2,19 @@ import {
|
|
|
2
2
|
assertSignal,
|
|
3
3
|
assertState,
|
|
4
4
|
waitUntil
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5I2BFXGD.js";
|
|
6
6
|
import {
|
|
7
7
|
make
|
|
8
8
|
} from "./chunk-RG24KSEB.js";
|
|
9
9
|
|
|
10
10
|
// src/internal/api/TestProgram.ts
|
|
11
|
-
import { Chunk, Clock, Effect, Layer, Ref, Scope, Stream
|
|
11
|
+
import { Chunk, Clock, Effect, Layer, Ref, Scope, Stream } from "effect";
|
|
12
|
+
import { TestClock } from "effect/testing";
|
|
12
13
|
import * as Logix from "@logixjs/core";
|
|
13
14
|
var defaultOptions = (options) => {
|
|
14
15
|
const base = options ?? {};
|
|
15
16
|
const userLayer = base.layer ?? Layer.empty;
|
|
16
|
-
const layer = Layer.mergeAll(
|
|
17
|
+
const layer = Layer.mergeAll(TestClock.layer(), userLayer);
|
|
17
18
|
return {
|
|
18
19
|
...base,
|
|
19
20
|
layer,
|
|
@@ -61,7 +62,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => Effect.gen(function* (
|
|
|
61
62
|
yield* Ref.update(traceRef, Chunk.append(event));
|
|
62
63
|
yield* Ref.update(actionsRef, Chunk.append(action));
|
|
63
64
|
})
|
|
64
|
-
).pipe(Effect.
|
|
65
|
+
).pipe((effect) => Effect.forkIn(effect, ctx.scope), Effect.asVoid);
|
|
65
66
|
yield* Stream.runForEach(
|
|
66
67
|
ctx.module.changes((s) => s),
|
|
67
68
|
(state) => Effect.gen(function* () {
|
|
@@ -69,10 +70,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => Effect.gen(function* (
|
|
|
69
70
|
const event = { _tag: "State", state, timestamp };
|
|
70
71
|
yield* Ref.update(traceRef, Chunk.append(event));
|
|
71
72
|
})
|
|
72
|
-
).pipe(Effect.
|
|
73
|
+
).pipe((effect) => Effect.forkIn(effect, ctx.scope), Effect.asVoid);
|
|
73
74
|
yield* TestClock.adjust(1);
|
|
74
|
-
yield* Effect.yieldNow
|
|
75
|
+
yield* Effect.yieldNow;
|
|
75
76
|
});
|
|
77
|
+
var runInProgramScope = (ctx, effect) => Effect.tryPromise({
|
|
78
|
+
try: () => ctx.runtime.runPromise(Effect.provideService(effect, Scope.Scope, ctx.scope)),
|
|
79
|
+
catch: (e) => e
|
|
80
|
+
}).pipe(Effect.orDie);
|
|
76
81
|
var runProgram = (program, body, options) => Effect.gen(function* () {
|
|
77
82
|
const traceRef = yield* Ref.make(Chunk.empty());
|
|
78
83
|
const actionsRef = yield* Ref.make(Chunk.empty());
|
|
@@ -93,31 +98,22 @@ var runProgram = (program, body, options) => Effect.gen(function* () {
|
|
|
93
98
|
}
|
|
94
99
|
};
|
|
95
100
|
const resolved = defaultOptions(options);
|
|
96
|
-
const ctx = yield* Effect.
|
|
97
|
-
Logix.Runtime.openProgram(program, resolved)
|
|
101
|
+
const ctx = yield* Effect.provideService(
|
|
102
|
+
Logix.Runtime.openProgram(program, resolved),
|
|
103
|
+
Logix.Debug.internal.currentDebugSinks,
|
|
104
|
+
[debugSink]
|
|
98
105
|
);
|
|
99
|
-
yield*
|
|
100
|
-
try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
|
|
101
|
-
catch: (e) => e
|
|
102
|
-
}).pipe(Effect.orDie);
|
|
106
|
+
yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
|
|
103
107
|
const api = makeTestApi(ctx, actionsRef);
|
|
104
|
-
yield*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
),
|
|
115
|
-
catch: (e) => e
|
|
116
|
-
}).pipe(Effect.orDie);
|
|
117
|
-
const finalState = yield* Effect.tryPromise({
|
|
118
|
-
try: () => ctx.runtime.runPromise(ctx.module.getState),
|
|
119
|
-
catch: (e) => e
|
|
120
|
-
}).pipe(Effect.orDie);
|
|
108
|
+
yield* runInProgramScope(ctx, body(api));
|
|
109
|
+
yield* runInProgramScope(
|
|
110
|
+
ctx,
|
|
111
|
+
Effect.gen(function* () {
|
|
112
|
+
yield* TestClock.adjust(1);
|
|
113
|
+
yield* Effect.yieldNow;
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
|
|
121
117
|
const actionsChunk = yield* Ref.get(actionsRef);
|
|
122
118
|
const traceChunk = yield* Ref.get(traceRef);
|
|
123
119
|
return make(
|
|
@@ -33,7 +33,8 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// src/internal/utils/waitUntil.ts
|
|
36
|
-
import { Effect as Effect2
|
|
36
|
+
import { Effect as Effect2 } from "effect";
|
|
37
|
+
import { TestClock } from "effect/testing";
|
|
37
38
|
var waitUntil = (check, options = {}) => Effect2.gen(function* () {
|
|
38
39
|
const maxAttempts = options.maxAttempts ?? 20;
|
|
39
40
|
const step = options.step ?? "10 millis";
|
|
@@ -45,7 +46,7 @@ var waitUntil = (check, options = {}) => Effect2.gen(function* () {
|
|
|
45
46
|
}
|
|
46
47
|
lastError = result.cause;
|
|
47
48
|
yield* TestClock.adjust(step);
|
|
48
|
-
yield* Effect2.yieldNow
|
|
49
|
+
yield* Effect2.yieldNow;
|
|
49
50
|
}
|
|
50
51
|
return yield* Effect2.fail(lastError);
|
|
51
52
|
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-FOYMJMJR.js";
|
|
4
|
+
|
|
5
|
+
// src/Act.ts
|
|
6
|
+
var Act_exports = {};
|
|
7
|
+
__export(Act_exports, {
|
|
8
|
+
advanceTicks: () => advanceTicks,
|
|
9
|
+
flushAllHostScheduler: () => flushAllHostScheduler,
|
|
10
|
+
makeTestHostScheduler: () => makeTestHostScheduler,
|
|
11
|
+
testHostSchedulerLayer: () => testHostSchedulerLayer,
|
|
12
|
+
tickSchedulerTestLayer: () => tickSchedulerTestLayer
|
|
13
|
+
});
|
|
14
|
+
import { Effect } from "effect";
|
|
15
|
+
import * as Logix from "@logixjs/core";
|
|
16
|
+
var makeTestHostScheduler = () => Logix.InternalContracts.makeDeterministicHostScheduler();
|
|
17
|
+
var testHostSchedulerLayer = (scheduler) => Logix.InternalContracts.hostSchedulerTestLayer(scheduler);
|
|
18
|
+
var tickSchedulerTestLayer = (config) => Logix.InternalContracts.tickSchedulerTestLayer(config);
|
|
19
|
+
var flushAllHostScheduler = (scheduler, options) => Effect.gen(function* () {
|
|
20
|
+
const maxTurns = options?.maxTurns ?? 1e3;
|
|
21
|
+
const settleYields = options?.settleYields ?? 8;
|
|
22
|
+
for (let turn = 0; turn < maxTurns; turn += 1) {
|
|
23
|
+
yield* Effect.sync(() => {
|
|
24
|
+
scheduler.flushAll({ maxTurns });
|
|
25
|
+
});
|
|
26
|
+
yield* Effect.yieldNow;
|
|
27
|
+
const { microtasks: microtasks2, macrotasks: macrotasks2 } = scheduler.getQueueSize();
|
|
28
|
+
if (microtasks2 !== 0 || macrotasks2 !== 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < settleYields; i += 1) {
|
|
32
|
+
yield* Effect.yieldNow;
|
|
33
|
+
}
|
|
34
|
+
const after = scheduler.getQueueSize();
|
|
35
|
+
if (after.microtasks === 0 && after.macrotasks === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const { microtasks, macrotasks } = scheduler.getQueueSize();
|
|
40
|
+
throw new Error(
|
|
41
|
+
`[LogixTest.Act.flushAllHostScheduler] Exceeded maxTurns=${maxTurns} (microtasks=${microtasks}, macrotasks=${macrotasks}).`
|
|
42
|
+
);
|
|
43
|
+
}).pipe(Effect.asVoid);
|
|
44
|
+
var advanceTicks = (args) => Effect.gen(function* () {
|
|
45
|
+
const start = args.getTickSeq();
|
|
46
|
+
const expected = start + Math.max(0, args.n);
|
|
47
|
+
const maxTurns = args.maxTurns ?? 1e3;
|
|
48
|
+
for (let turn = 0; turn < maxTurns; turn += 1) {
|
|
49
|
+
yield* flushAllHostScheduler(args.scheduler, { maxTurns });
|
|
50
|
+
const current = args.getTickSeq();
|
|
51
|
+
if (current >= expected) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const end = args.getTickSeq();
|
|
56
|
+
throw new Error(`[LogixTest.Act.advanceTicks] Expected >=${args.n} ticks, got ${end - start}.`);
|
|
57
|
+
}).pipe(Effect.asVoid);
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
makeTestHostScheduler,
|
|
61
|
+
testHostSchedulerLayer,
|
|
62
|
+
tickSchedulerTestLayer,
|
|
63
|
+
flushAllHostScheduler,
|
|
64
|
+
advanceTicks,
|
|
65
|
+
Act_exports
|
|
66
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/internal/runtime/runTest.ts
|
|
2
|
-
import { Effect
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { TestClock } from "effect/testing";
|
|
3
4
|
var runTest = (effect) => {
|
|
4
|
-
const program = Effect.scoped(effect).pipe(Effect.provide(
|
|
5
|
+
const program = Effect.scoped(effect).pipe(Effect.provide(TestClock.layer()));
|
|
5
6
|
return Effect.runPromise(program);
|
|
6
7
|
};
|
|
7
8
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runProgram
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3XOKB7L4.js";
|
|
4
4
|
import {
|
|
5
5
|
expectNoError
|
|
6
6
|
} from "./chunk-RG24KSEB.js";
|
|
7
7
|
import {
|
|
8
8
|
runTest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OO3UZI3U.js";
|
|
10
10
|
import {
|
|
11
11
|
__commonJS,
|
|
12
12
|
__export,
|