@flemist/test-variants 5.0.11 → 5.0.12

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,6 +1,6 @@
1
1
  import { timeControllerDefault as K } from "@flemist/time-controller";
2
2
  import { formatAny as de, deepCloneJsonLike as Je } from "@flemist/simple-utils";
3
- import { isPromiseLike as M, waitMicrotasks as Xe, combineAbortSignals as oe } from "@flemist/async-utils";
3
+ import { isPromiseLike as T, waitMicrotasks as Xe, combineAbortSignals as oe } from "@flemist/async-utils";
4
4
  import { AbortError as Ze, AbortControllerFast as ie } from "@flemist/abort-controller-fast";
5
5
  import { poolWait as se, Pool as Ke } from "@flemist/time-limits";
6
6
  function Q() {
@@ -41,7 +41,7 @@ const me = (e, n) => {
41
41
  maxStringLength: 5e3,
42
42
  dontExpandClassInstances: !0,
43
43
  dontExpandFunctions: !0
44
- }), x = {
44
+ }), S = {
45
45
  start: !0,
46
46
  progress: 5e3,
47
47
  completed: !0,
@@ -61,15 +61,15 @@ const me = (e, n) => {
61
61
  format: ge
62
62
  };
63
63
  function pe(e) {
64
- return e === !1 ? rt : e === !0 || !e ? x : {
65
- start: e.start ?? x.start,
66
- progress: e.progress ?? x.progress,
67
- completed: e.completed ?? x.completed,
68
- error: e.error ?? x.error,
69
- modeChange: e.modeChange ?? x.modeChange,
70
- debug: e.debug ?? x.debug,
71
- func: e.func ?? x.func,
72
- format: e.format ?? x.format
64
+ return e === !1 ? rt : e === !0 || !e ? S : {
65
+ start: e.start ?? S.start,
66
+ progress: e.progress ?? S.progress,
67
+ completed: e.completed ?? S.completed,
68
+ error: e.error ?? S.error,
69
+ modeChange: e.modeChange ?? S.modeChange,
70
+ debug: e.debug ?? S.debug,
71
+ func: e.func ?? S.func,
72
+ format: e.format ?? S.format
73
73
  };
74
74
  }
75
75
  function nt(e, n) {
@@ -96,37 +96,44 @@ function ae(e, n) {
96
96
  return typeof e == "number" ? { iterationsAsync: 0, iterationsSync: e } : e != null && typeof e == "object" ? e : n ? { iterationsAsync: 1, iterationsSync: 0 } : { iterationsAsync: 0, iterationsSync: 1 };
97
97
  }
98
98
  function st(e, n) {
99
- const t = n.log, i = n.pauseDebuggerOnError ?? !0;
100
- let o = null, a = 0;
101
- function r(l, u, c) {
102
- o == null && (o = { error: l, args: u, tests: c }, t.error && t.func(
99
+ const t = n.log, i = n.pauseDebuggerOnError ?? !0, o = n.onStart, s = n.onEnd;
100
+ let r = null, l = 0;
101
+ function f(m, c, b) {
102
+ r == null && (r = { error: m, args: c, tests: b }, t.error && t.func(
103
103
  "error",
104
- `[test-variants] error variant: ${t.format(u)}
105
- tests: ${c}
106
- ${t.format(l)}`
104
+ `[test-variants] error variant: ${t.format(c)}
105
+ tests: ${b}
106
+ ${t.format(m)}`
107
107
  ));
108
- const d = Date.now();
108
+ const y = Date.now();
109
109
  if (i)
110
110
  debugger;
111
- if (Date.now() - d > ot && a < it) {
111
+ if (Date.now() - y > ot && l < it) {
112
112
  t.func(
113
113
  "debug",
114
- `[test-variants] debug iteration: ${a}`
115
- ), a++;
114
+ `[test-variants] debug iteration: ${l}`
115
+ ), l++;
116
116
  return;
117
117
  }
118
- const y = o;
119
- throw o = null, n.onError && n.onError(y), y.error;
118
+ const h = r;
119
+ throw r = null, n.onError && n.onError(h), h.error;
120
120
  }
121
- return function(u, c, d) {
121
+ return function(c, b, y) {
122
+ o && o({ args: c, tests: b });
122
123
  try {
123
- const h = e(u, d);
124
- return M(h) ? h.then(
125
- (y) => ae(y, !0),
126
- (y) => r(y, u, c)
127
- ) : ae(h, !1);
128
- } catch (h) {
129
- return h instanceof I ? void 0 : r(h, u, c);
124
+ const d = e(c, y);
125
+ if (T(d))
126
+ return d.then(
127
+ (v) => {
128
+ const x = ae(v, !0);
129
+ return s && s({ args: c, tests: b, result: x }), x;
130
+ },
131
+ (v) => (s && !(v instanceof I) && s({ args: c, tests: b, error: v }), f(v, c, b))
132
+ );
133
+ const h = ae(d, !1);
134
+ return s && s({ args: c, tests: b, result: h }), h;
135
+ } catch (d) {
136
+ return d instanceof I ? void 0 : (s && s({ args: c, tests: b, error: d }), f(d, c, b));
130
137
  }
131
138
  };
132
139
  }
@@ -137,17 +144,17 @@ function U(e, n, t) {
137
144
  return -1;
138
145
  }
139
146
  function le(e, n, t, i) {
140
- const o = Object.keys(e.templates), a = {}, r = [], l = [], u = [], c = o.length;
141
- for (let d = 0; d < c; d++) {
142
- const h = o[d];
143
- a[h] = void 0, r.push(-1), l.push(void 0), u.push(null);
147
+ const o = Object.keys(e.templates), s = {}, r = [], l = [], f = [], m = o.length;
148
+ for (let c = 0; c < m; c++) {
149
+ const b = o[c];
150
+ s[b] = void 0, r.push(-1), l.push(void 0), f.push(null);
144
151
  }
145
152
  return {
146
- args: a,
153
+ args: s,
147
154
  argsNames: o,
148
155
  indexes: r,
149
156
  argValues: l,
150
- argLimits: u,
157
+ argLimits: f,
151
158
  attempts: 0,
152
159
  templates: e,
153
160
  limitArgOnError: t,
@@ -155,38 +162,38 @@ function le(e, n, t, i) {
155
162
  includeErrorVariant: i ?? !1
156
163
  };
157
164
  }
158
- function O(e, n) {
165
+ function L(e, n) {
159
166
  const t = e.templates.templates[n], i = e.templates.extra[n];
160
167
  let o;
161
168
  if (typeof t == "function" ? o = t(e.args) : o = t, i == null)
162
169
  return o;
163
- let a = null;
170
+ let s = null;
164
171
  const r = i.length;
165
172
  for (let l = 0; l < r; l++) {
166
- const u = i[l];
167
- U(o, u, e.equals) < 0 && (a == null ? a = [...o, u] : a.push(u));
173
+ const f = i[l];
174
+ U(o, f, e.equals) < 0 && (s == null ? s = [...o, f] : s.push(f));
168
175
  }
169
- return a ?? o;
176
+ return s ?? o;
170
177
  }
171
- function w(e, n, t) {
178
+ function M(e, n, t) {
172
179
  const i = e.argValues[n].length;
173
180
  if (i === 0)
174
181
  return -1;
175
182
  const o = e.argLimits[n];
176
183
  if (o == null)
177
184
  return i - 1;
178
- let a = e.limitArgOnError;
179
- if (typeof a == "function") {
185
+ let s = e.limitArgOnError;
186
+ if (typeof s == "function") {
180
187
  const r = e.argsNames[n];
181
- a = a({
188
+ s = s({
182
189
  name: r,
183
190
  values: e.argValues[n],
184
191
  maxValueIndex: o
185
192
  });
186
193
  }
187
- return !t || a ? Math.min(o, i - 1) : i - 1;
194
+ return !t || s ? Math.min(o, i - 1) : i - 1;
188
195
  }
189
- function T(e) {
196
+ function V(e) {
190
197
  const n = e.indexes.length;
191
198
  for (let t = 0; t < n; t++) {
192
199
  const i = e.argLimits[t];
@@ -200,7 +207,7 @@ function T(e) {
200
207
  }
201
208
  return !e.includeErrorVariant;
202
209
  }
203
- function C(e) {
210
+ function O(e) {
204
211
  const n = e.indexes.length;
205
212
  for (let t = 0; t < n; t++)
206
213
  e.indexes[t] = -1, e.argValues[t] = void 0, e.args[e.argsNames[t]] = void 0;
@@ -208,125 +215,125 @@ function C(e) {
208
215
  function he(e) {
209
216
  let n = !1, t = !0;
210
217
  const i = e.indexes.length;
211
- let o = i, a = !1, r = 0;
218
+ let o = i, s = !1, r = 0;
212
219
  for (; r < i; r++) {
213
220
  const l = e.argValues[r] == null;
214
- (l || a) && (l && (n = !0), e.argValues[r] = O(
221
+ (l || s) && (l && (n = !0), e.argValues[r] = L(
215
222
  e,
216
223
  e.argsNames[r]
217
224
  ));
218
- const u = w(
225
+ const f = M(
219
226
  e,
220
227
  r,
221
228
  r > o
222
229
  );
223
- if (u < 0) {
230
+ if (f < 0) {
224
231
  t = !1, e.indexes[r] = -1;
225
232
  break;
226
233
  }
227
- l && (e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0]), (a || e.indexes[r] > u) && (e.indexes[r] = u, e.args[e.argsNames[r]] = e.argValues[r][u], a = !0), o === i && e.indexes[r] < u && (o = r);
234
+ l && (e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0]), (s || e.indexes[r] > f) && (e.indexes[r] = f, e.args[e.argsNames[r]] = e.argValues[r][f], s = !0), o === i && e.indexes[r] < f && (o = r);
228
235
  }
229
- if (T(e))
230
- return C(e), !1;
236
+ if (V(e))
237
+ return O(e), !1;
231
238
  if (n && t)
232
239
  return !0;
233
240
  for (r--; r >= 0; r--) {
234
241
  if (e.argValues[r] == null)
235
242
  continue;
236
243
  let l = r > o;
237
- const u = w(e, r, l), c = e.indexes[r] + 1;
238
- if (c <= u) {
239
- e.indexes[r] = c, e.args[e.argsNames[r]] = e.argValues[r][c], c < u && (l = !0);
240
- for (let d = r + 1; d < i; d++)
241
- e.args[e.argsNames[d]] = void 0;
244
+ const f = M(e, r, l), m = e.indexes[r] + 1;
245
+ if (m <= f) {
246
+ e.indexes[r] = m, e.args[e.argsNames[r]] = e.argValues[r][m], m < f && (l = !0);
247
+ for (let c = r + 1; c < i; c++)
248
+ e.args[e.argsNames[c]] = void 0;
242
249
  for (r++; r < i; r++) {
243
- e.argValues[r] = O(
250
+ e.argValues[r] = L(
244
251
  e,
245
252
  e.argsNames[r]
246
253
  );
247
- const d = w(e, r, l);
248
- if (d < 0)
254
+ const c = M(e, r, l);
255
+ if (c < 0)
249
256
  break;
250
- e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0], d > 0 && (l = !0);
257
+ e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0], c > 0 && (l = !0);
251
258
  }
252
259
  if (r >= i)
253
- return T(e) ? (C(e), !1) : !0;
260
+ return V(e) ? (O(e), !1) : !0;
254
261
  }
255
262
  }
256
- return C(e), !1;
263
+ return O(e), !1;
257
264
  }
258
265
  function z(e) {
259
- T(e) && C(e);
266
+ V(e) && O(e);
260
267
  let n = !1, t = !0;
261
268
  const i = e.indexes.length;
262
- let o = i, a = !1, r = 0;
269
+ let o = i, s = !1, r = 0;
263
270
  for (; r < i; r++) {
264
271
  const l = e.argValues[r] == null;
265
- (l || a) && (l && (n = !0), e.argValues[r] = O(
272
+ (l || s) && (l && (n = !0), e.argValues[r] = L(
266
273
  e,
267
274
  e.argsNames[r]
268
275
  ));
269
- const u = w(
276
+ const f = M(
270
277
  e,
271
278
  r,
272
279
  r > o
273
280
  );
274
- if (u < 0) {
281
+ if (f < 0) {
275
282
  t = !1, e.indexes[r] = -1;
276
283
  break;
277
284
  }
278
- l && (e.indexes[r] = u, e.args[e.argsNames[r]] = e.argValues[r][u]), (a || e.indexes[r] > u) && (e.indexes[r] = u, e.args[e.argsNames[r]] = e.argValues[r][u], a = !0), o === i && e.indexes[r] < u && (o = r);
285
+ l && (e.indexes[r] = f, e.args[e.argsNames[r]] = e.argValues[r][f]), (s || e.indexes[r] > f) && (e.indexes[r] = f, e.args[e.argsNames[r]] = e.argValues[r][f], s = !0), o === i && e.indexes[r] < f && (o = r);
279
286
  }
280
- if ((n || a) && t && !T(e))
287
+ if ((n || s) && t && !V(e))
281
288
  return !0;
282
289
  for (r--; r >= 0; r--) {
283
290
  if (e.argValues[r] == null)
284
291
  continue;
285
292
  let l = r > o;
286
- const u = w(e, r, l);
287
- let c = e.indexes[r] - 1;
288
- if (c > u && (c = u), c >= 0) {
289
- e.indexes[r] = c, e.args[e.argsNames[r]] = e.argValues[r][c], c < u && (l = !0);
290
- for (let d = r + 1; d < i; d++)
291
- e.args[e.argsNames[d]] = void 0;
293
+ const f = M(e, r, l);
294
+ let m = e.indexes[r] - 1;
295
+ if (m > f && (m = f), m >= 0) {
296
+ e.indexes[r] = m, e.args[e.argsNames[r]] = e.argValues[r][m], m < f && (l = !0);
297
+ for (let c = r + 1; c < i; c++)
298
+ e.args[e.argsNames[c]] = void 0;
292
299
  for (r++; r < i; r++) {
293
- e.argValues[r] = O(
300
+ e.argValues[r] = L(
294
301
  e,
295
302
  e.argsNames[r]
296
303
  );
297
- const d = w(e, r, l);
298
- if (d < 0)
304
+ const c = M(e, r, l);
305
+ if (c < 0)
299
306
  break;
300
- e.indexes[r] = d, e.args[e.argsNames[r]] = e.argValues[r][d], d > 0 && (l = !0);
307
+ e.indexes[r] = c, e.args[e.argsNames[r]] = e.argValues[r][c], c > 0 && (l = !0);
301
308
  }
302
309
  if (r >= i)
303
310
  return !0;
304
311
  }
305
312
  }
306
- return C(e), !1;
313
+ return O(e), !1;
307
314
  }
308
315
  function at(e, n) {
309
- C(e);
316
+ O(e);
310
317
  const t = e.argsNames, i = t.length;
311
318
  let o = !1;
312
- for (let a = 0; a < i; a++) {
313
- const r = t[a], l = n[r];
319
+ for (let s = 0; s < i; s++) {
320
+ const r = t[s], l = n[r];
314
321
  if (l === void 0)
315
322
  return null;
316
- e.argValues[a] = O(e, r);
317
- const u = w(e, a, o);
318
- if (u < 0)
323
+ e.argValues[s] = L(e, r);
324
+ const f = M(e, s, o);
325
+ if (f < 0)
319
326
  return null;
320
- const c = U(
321
- e.argValues[a],
327
+ const m = U(
328
+ e.argValues[s],
322
329
  l,
323
330
  e.equals
324
331
  );
325
- if (c < 0 || c > u)
332
+ if (m < 0 || m > f)
326
333
  return null;
327
- e.indexes[a] = c, e.args[e.argsNames[a]] = e.argValues[a][c], e.indexes[a] < u && (o = !0);
334
+ e.indexes[s] = m, e.args[e.argsNames[s]] = e.argValues[s][m], e.indexes[s] < f && (o = !0);
328
335
  }
329
- return T(e) ? null : e.indexes.slice();
336
+ return V(e) ? null : e.indexes.slice();
330
337
  }
331
338
  function lt(e) {
332
339
  const n = e.indexes.length;
@@ -334,23 +341,23 @@ function lt(e) {
334
341
  return !1;
335
342
  let t = !1;
336
343
  for (let i = 0; i < n; i++) {
337
- e.argValues[i] = O(e, e.argsNames[i]);
338
- const o = w(e, i, t);
344
+ e.argValues[i] = L(e, e.argsNames[i]);
345
+ const o = M(e, i, t);
339
346
  if (o < 0)
340
347
  return Math.random() < 0.5 ? he(e) : z(e);
341
348
  e.indexes[i] = Math.floor(Math.random() * (o + 1)), e.args[e.argsNames[i]] = e.argValues[i][e.indexes[i]], e.indexes[i] < o && (t = !0);
342
349
  }
343
- return T(e) ? z(e) : !0;
350
+ return V(e) ? z(e) : !0;
344
351
  }
345
352
  function _(e) {
346
353
  return e.mode === "forward" || e.mode === "backward";
347
354
  }
348
355
  function ut(e, n, t, i) {
349
- const o = n[t], a = e.templates[t];
350
- if (typeof a != "function") {
351
- if (U(a, o, i) >= 0)
356
+ const o = n[t], s = e.templates[t];
357
+ if (typeof s != "function") {
358
+ if (U(s, o, i) >= 0)
352
359
  return;
353
- a.push(o);
360
+ s.push(o);
354
361
  return;
355
362
  }
356
363
  const r = e.extra[t];
@@ -385,25 +392,25 @@ function dt(e) {
385
392
  equals: t,
386
393
  limitArgOnError: i,
387
394
  includeErrorVariant: o,
388
- getSeed: a,
395
+ getSeed: s,
389
396
  iterationModes: r,
390
397
  onModeChange: l,
391
- limitCompletionCount: u,
392
- limitTests: c,
393
- limitTime: d
394
- } = e, h = e.timeController ?? K, y = {
398
+ limitCompletionCount: f,
399
+ limitTests: m,
400
+ limitTime: c
401
+ } = e, b = e.timeController ?? K, y = {
395
402
  templates: Je(n),
396
403
  extra: {}
397
- }, p = r == null || r.length === 0 ? ct : r, b = [];
398
- let E = null, L = null, g = 0, S = 0, V = !1, P = 0;
404
+ }, d = r == null || r.length === 0 ? ct : r, h = [];
405
+ let v = null, x = null, p = 0, w = 0, A = !1, P = 0;
399
406
  function $() {
400
- V || (V = !0, P = h.now(), xe(), g = 0, te(), we());
401
- }
402
- function xe() {
403
- for (let s = 0, f = p.length; s < f; s++)
404
- b.push(Se());
407
+ A || (A = !0, P = b.now(), Se(), p = 0, te(), we());
405
408
  }
406
409
  function Se() {
410
+ for (let a = 0, u = d.length; a < u; a++)
411
+ h.push(xe());
412
+ }
413
+ function xe() {
407
414
  return {
408
415
  navigationState: le(
409
416
  y,
@@ -419,7 +426,7 @@ function dt(e) {
419
426
  };
420
427
  }
421
428
  function we() {
422
- E = le(
429
+ v = le(
423
430
  y,
424
431
  t ?? null,
425
432
  // Initial values; overwritten in calcIndexes before each use
@@ -429,32 +436,32 @@ function dt(e) {
429
436
  }
430
437
  function te() {
431
438
  l?.({
432
- mode: p[g],
433
- modeIndex: g,
434
- tests: S
439
+ mode: d[p],
440
+ modeIndex: p,
441
+ tests: w
435
442
  });
436
443
  }
437
- function Me(s) {
438
- $(), ue(y.templates, s) && ft(y, s, t);
444
+ function Me(a) {
445
+ $(), ue(y.templates, a) && ft(y, a, t);
439
446
  }
440
- function re(s, f) {
441
- return $(), ue(y.templates, s) ? (E.limitArgOnError = f?.limitArg ?? i ?? null, E.includeErrorVariant = f?.includeLimit ?? o ?? !1, at(E, s)) : null;
447
+ function re(a, u) {
448
+ return $(), ue(y.templates, a) ? (v.limitArgOnError = u?.limitArg ?? i ?? null, v.includeErrorVariant = u?.includeLimit ?? o ?? !1, at(v, a)) : null;
442
449
  }
443
- function Ie(s) {
444
- const f = s?.args;
445
- if (f == null)
450
+ function Ie(a) {
451
+ const u = a?.args;
452
+ if (u == null)
446
453
  return;
447
454
  $();
448
- const m = re(f);
449
- if (m != null) {
450
- L = {
451
- args: f,
452
- error: s?.error,
453
- tests: s?.tests ?? S
454
- }, E.argLimits = m;
455
- for (let v = 0, D = b.length; v < D; v++) {
456
- const j = b[v].navigationState;
457
- j.argLimits = m;
455
+ const g = re(u);
456
+ if (g != null) {
457
+ x = {
458
+ args: u,
459
+ error: a?.error,
460
+ tests: a?.tests ?? w
461
+ }, v.argLimits = g;
462
+ for (let E = 0, D = h.length; E < D; E++) {
463
+ const j = h[E].navigationState;
464
+ j.argLimits = g;
458
465
  }
459
466
  }
460
467
  }
@@ -466,9 +473,9 @@ function dt(e) {
466
473
  if (!Ae())
467
474
  return null;
468
475
  for (; ; ) {
469
- const s = qe();
470
- if (s != null)
471
- return b[g].testsInLastTurn++, S++, s;
476
+ const a = qe();
477
+ if (a != null)
478
+ return h[p].testsInLastTurn++, w++, a;
472
479
  if ($e()) {
473
480
  if (!Ge())
474
481
  return null;
@@ -482,180 +489,180 @@ function dt(e) {
482
489
  return !(Ce() || Oe() || G() && (Le() || !Ne()) || !Pe());
483
490
  }
484
491
  function Ce() {
485
- return c != null && S >= c;
492
+ return m != null && w >= m;
486
493
  }
487
494
  function Oe() {
488
- return d != null && h.now() - P >= d;
495
+ return c != null && b.now() - P >= c;
489
496
  }
490
497
  function Le() {
491
498
  if (!G())
492
499
  throw new Error("Unexpected behavior");
493
- return u != null && u <= 0;
500
+ return f != null && f <= 0;
494
501
  }
495
502
  function Ne() {
496
503
  if (!G())
497
504
  throw new Error("Unexpected behavior");
498
- for (let s = 0, f = p.length; s < f; s++)
499
- if (A(p[s]) && R(s))
505
+ for (let a = 0, u = d.length; a < u; a++)
506
+ if (C(d[a]) && R(a))
500
507
  return !0;
501
508
  return !1;
502
509
  }
503
510
  function Pe() {
504
- for (let s = 0, f = p.length; s < f; s++)
505
- if (R(s))
511
+ for (let a = 0, u = d.length; a < u; a++)
512
+ if (R(a))
506
513
  return !0;
507
514
  return !1;
508
515
  }
509
516
  function $e() {
510
- g++;
511
- const s = g >= p.length;
512
- return s && (g = 0), te(), s;
517
+ p++;
518
+ const a = p >= d.length;
519
+ return a && (p = 0), te(), a;
513
520
  }
514
521
  function Ge() {
515
522
  if (G()) {
516
- const s = De();
517
- if (u != null && s >= u)
523
+ const a = De();
524
+ if (f != null && a >= f)
518
525
  return !1;
519
526
  }
520
527
  return !0;
521
528
  }
522
529
  function G() {
523
- for (let s = 0, f = p.length; s < f; s++)
524
- if (_(p[s]))
530
+ for (let a = 0, u = d.length; a < u; a++)
531
+ if (_(d[a]))
525
532
  return !0;
526
533
  return !1;
527
534
  }
528
535
  function De() {
529
- let s = !1, f = 1 / 0;
530
- for (let m = 0, v = b.length; m < v; m++) {
531
- const D = b[m], j = p[m];
532
- _(j) && (s = !0, R(m) && D.completedCount < f && (f = D.completedCount));
536
+ let a = !1, u = 1 / 0;
537
+ for (let g = 0, E = h.length; g < E; g++) {
538
+ const D = h[g], j = d[g];
539
+ _(j) && (a = !0, R(g) && D.completedCount < u && (u = D.completedCount));
533
540
  }
534
- if (!s)
541
+ if (!a)
535
542
  throw new Error("Unexpected behavior");
536
- return f;
543
+ return u;
537
544
  }
538
- function R(s) {
539
- const f = p[s], m = b[s];
540
- return f.limitTests != null && f.limitTests <= 0 || A(f) && (f.cycles != null && f.cycles <= 0 || f.attemptsPerVariant != null && f.attemptsPerVariant <= 0) ? !1 : m.tryNextVariantAttempts < 2;
545
+ function R(a) {
546
+ const u = d[a], g = h[a];
547
+ return u.limitTests != null && u.limitTests <= 0 || C(u) && (u.cycles != null && u.cycles <= 0 || u.attemptsPerVariant != null && u.attemptsPerVariant <= 0) ? !1 : g.tryNextVariantAttempts < 2;
541
548
  }
542
549
  function _e() {
543
- g = 0;
544
- for (let s = 0, f = b.length; s < f; s++) {
545
- const m = b[s];
546
- m.testsInLastTurn = 0, m.startTime = null;
550
+ p = 0;
551
+ for (let a = 0, u = h.length; a < u; a++) {
552
+ const g = h[a];
553
+ g.testsInLastTurn = 0, g.startTime = null;
547
554
  }
548
555
  }
549
556
  function qe() {
550
- let s = 0;
551
- for (; s < 2; ) {
557
+ let a = 0;
558
+ for (; a < 2; ) {
552
559
  if (!Ue())
553
560
  return null;
554
- const f = je();
555
- if (f != null)
556
- return f;
557
- if (A(p[g]) && Fe())
561
+ const u = je();
562
+ if (u != null)
563
+ return u;
564
+ if (C(d[p]) && Fe())
558
565
  return null;
559
- s++;
566
+ a++;
560
567
  }
561
568
  return null;
562
569
  }
563
570
  function Ue() {
564
- const s = p[g];
565
- return !(Be() || ke() || A(s) && !Re(g));
571
+ const a = d[p];
572
+ return !(Be() || ke() || C(a) && !Re(p));
566
573
  }
567
574
  function Be() {
568
- const s = p[g], f = b[g];
569
- return s.limitTests != null && f.testsInLastTurn >= s.limitTests;
575
+ const a = d[p], u = h[p];
576
+ return a.limitTests != null && u.testsInLastTurn >= a.limitTests;
570
577
  }
571
578
  function ke() {
572
- const s = p[g], f = b[g];
573
- return s.limitTime != null && f.startTime != null && h.now() - f.startTime >= s.limitTime;
579
+ const a = d[p], u = h[p];
580
+ return a.limitTime != null && u.startTime != null && b.now() - u.startTime >= a.limitTime;
574
581
  }
575
- function A(s) {
576
- return _(s);
582
+ function C(a) {
583
+ return _(a);
577
584
  }
578
- function Re(s) {
579
- const f = p[s], m = b[s];
580
- if (!A(f))
585
+ function Re(a) {
586
+ const u = d[a], g = h[a];
587
+ if (!C(u))
581
588
  throw new Error("Unexpected behavior");
582
- return m.cycleCount < (f.cycles ?? 1);
589
+ return g.cycleCount < (u.cycles ?? 1);
583
590
  }
584
591
  function Fe() {
585
- const s = p[g], f = b[g];
586
- if (!A(s))
592
+ const a = d[p], u = h[p];
593
+ if (!C(a))
587
594
  throw new Error("Unexpected behavior");
588
- return f.cycleCount++, f.cycleCount >= (s.cycles ?? 1) ? (f.cycleCount = 0, f.completedCount++, !0) : !1;
595
+ return u.cycleCount++, u.cycleCount >= (a.cycles ?? 1) ? (u.cycleCount = 0, u.completedCount++, !0) : !1;
589
596
  }
590
597
  function je() {
591
- const s = p[g], f = b[g], m = f.navigationState;
592
- if (N(s)) {
598
+ const a = d[p], u = h[p], g = u.navigationState;
599
+ if (N(a)) {
593
600
  if (F())
594
601
  return null;
595
- const v = We();
596
- if (v != null)
597
- return f.startTime == null && (f.startTime = h.now()), v;
602
+ const E = We();
603
+ if (E != null)
604
+ return u.startTime == null && (u.startTime = b.now()), E;
598
605
  }
599
- return He() ? (f.tryNextVariantAttempts = 0, N(s) && ze(), f.startTime == null && (f.startTime = h.now()), ne(m.args)) : (f.tryNextVariantAttempts++, null);
606
+ return He() ? (u.tryNextVariantAttempts = 0, N(a) && ze(), u.startTime == null && (u.startTime = b.now()), ne(g.args)) : (u.tryNextVariantAttempts++, null);
600
607
  }
601
608
  function We() {
602
- const s = p[g], m = b[g].navigationState;
603
- if (!N(s))
609
+ const a = d[p], g = h[p].navigationState;
610
+ if (!N(a))
604
611
  throw new Error("Unexpected behavior");
605
612
  if (F())
606
613
  throw new Error("Unexpected behavior");
607
- const v = s.attemptsPerVariant ?? 1;
608
- return m.attempts > 0 && m.attempts < v ? T(m) ? null : (m.attempts++, ne(m.args)) : null;
614
+ const E = a.attemptsPerVariant ?? 1;
615
+ return g.attempts > 0 && g.attempts < E ? V(g) ? null : (g.attempts++, ne(g.args)) : null;
609
616
  }
610
617
  function ze() {
611
- const s = p[g], m = b[g].navigationState;
612
- if (!N(s))
618
+ const a = d[p], g = h[p].navigationState;
619
+ if (!N(a))
613
620
  throw new Error("Unexpected behavior");
614
621
  if (F())
615
622
  throw new Error("Unexpected behavior");
616
- m.attempts = 1;
623
+ g.attempts = 1;
617
624
  }
618
- function N(s) {
619
- return _(s);
625
+ function N(a) {
626
+ return _(a);
620
627
  }
621
628
  function F() {
622
- const s = p[g];
623
- if (!N(s))
629
+ const a = d[p];
630
+ if (!N(a))
624
631
  throw new Error("Unexpected behavior");
625
- return (s.attemptsPerVariant ?? 1) <= 0;
632
+ return (a.attemptsPerVariant ?? 1) <= 0;
626
633
  }
627
634
  function He() {
628
- const s = p[g], m = b[g].navigationState;
629
- switch (s.mode) {
635
+ const a = d[p], g = h[p].navigationState;
636
+ switch (a.mode) {
630
637
  case "forward":
631
- return he(m);
638
+ return he(g);
632
639
  case "backward":
633
- return z(m);
640
+ return z(g);
634
641
  case "random":
635
- return lt(m);
642
+ return lt(g);
636
643
  default:
637
- throw new Error(`Unknown mode: ${s.mode}`);
644
+ throw new Error(`Unknown mode: ${a.mode}`);
638
645
  }
639
646
  }
640
- function ne(s) {
641
- const f = { ...s };
642
- return a != null && (f.seed = a({ tests: S })), f;
647
+ function ne(a) {
648
+ const u = { ...a };
649
+ return s != null && (u.seed = s({ tests: w })), u;
643
650
  }
644
651
  return {
645
652
  get limit() {
646
- return L;
653
+ return x;
647
654
  },
648
655
  get modeIndex() {
649
- return g;
656
+ return p;
650
657
  },
651
658
  get modeConfigs() {
652
- return p;
659
+ return d;
653
660
  },
654
661
  get modeStates() {
655
- return b;
662
+ return h;
656
663
  },
657
664
  get tests() {
658
- return S;
665
+ return w;
659
666
  },
660
667
  calcIndexes: re,
661
668
  extendTemplates: Me,
@@ -702,7 +709,7 @@ function gt(e) {
702
709
  };
703
710
  }
704
711
  function pt(e) {
705
- const n = e?.saveErrorVariants, t = n && e.createSaveErrorVariantsStore ? e.createSaveErrorVariantsStore(n) : null, i = e?.findBestError, { parallel: o, sequentialOnError: a } = gt(
712
+ const n = e?.saveErrorVariants, t = n && e.createSaveErrorVariantsStore ? e.createSaveErrorVariantsStore(n) : null, i = e?.findBestError, { parallel: o, sequentialOnError: s } = gt(
706
713
  e?.parallel
707
714
  );
708
715
  return {
@@ -716,21 +723,21 @@ function pt(e) {
716
723
  dontThrowIfError: i?.dontThrowIfError,
717
724
  timeController: e?.timeController ?? K,
718
725
  parallel: o,
719
- sequentialOnError: a
726
+ sequentialOnError: s
720
727
  };
721
728
  }
722
729
  function B(e, n, t) {
723
- const { options: i, variantsIterator: o } = e, a = o.limit?.args ?? n;
730
+ const { options: i, variantsIterator: o } = e, s = o.limit?.args ?? n;
724
731
  if (!i.store)
725
732
  return;
726
- const r = i.store.save(a);
733
+ const r = i.store.save(s);
727
734
  if (t)
728
735
  return r;
729
736
  }
730
737
  function ht(e, n, t, i) {
731
- const { abortControllerParallel: o, state: a, options: r } = e, { logOptions: l } = r;
738
+ const { abortControllerParallel: o, state: s, options: r } = e, { logOptions: l } = r;
732
739
  if (e.options.findBestError)
733
- e.variantsIterator.addLimit({ args: n, error: t, tests: i }), a.debugMode = !1, B(e, n, !1), r.sequentialOnError && !o.signal.aborted ? (l.debug && l.func(
740
+ e.variantsIterator.addLimit({ args: n, error: t, tests: i }), s.debugMode = !1, B(e, n, !1), r.sequentialOnError && !o.signal.aborted ? (l.debug && l.func(
734
741
  "debug",
735
742
  "[test-variants] sequentialOnError: aborting parallel, switching to sequential"
736
743
  ), o.abort(new I())) : l.debug && l.func(
@@ -755,9 +762,9 @@ function ce(e, n, t, i) {
755
762
  o.debugMode = !1;
756
763
  return;
757
764
  }
758
- const a = B(e, n, !0);
759
- if (a)
760
- return a.then(() => {
765
+ const s = B(e, n, !0);
766
+ if (s)
767
+ return s.then(() => {
761
768
  throw t;
762
769
  });
763
770
  throw t;
@@ -799,12 +806,12 @@ function Et(e, n) {
799
806
  let t = "[test-variants] start";
800
807
  n != null && (t += `, memory: ${H(n)}`), e.func("start", t);
801
808
  }
802
- function xt(e) {
809
+ function St(e) {
803
810
  const { options: n, state: t } = e, { logOptions: i, timeController: o } = n;
804
811
  if (!i.completed)
805
812
  return;
806
- const a = o.now() - t.startTime;
807
- let r = `[test-variants] end, tests: ${t.tests} (${ee(a)}), async: ${t.iterationsAsync}`;
813
+ const s = o.now() - t.startTime;
814
+ let r = `[test-variants] end, tests: ${t.tests} (${ee(s)}), async: ${t.iterationsAsync}`;
808
815
  if (t.startMemory != null) {
809
816
  const l = Q();
810
817
  l != null && (r += `, memory: ${be(l, t.startMemory)}`);
@@ -818,18 +825,18 @@ function ye(e) {
818
825
  `[test-variants] ${vt(o.mode, o.modeIndex)}`
819
826
  ), t.pendingModeChange = null);
820
827
  }
821
- function St(e) {
822
- const { options: n, state: t } = e, { logOptions: i, timeController: o } = n, a = o.now();
823
- if (!i.progress || a - t.prevLogTime < i.progress)
828
+ function xt(e) {
829
+ const { options: n, state: t } = e, { logOptions: i, timeController: o } = n, s = o.now();
830
+ if (!i.progress || s - t.prevLogTime < i.progress)
824
831
  return !1;
825
832
  ye(e);
826
- const r = a - t.startTime;
833
+ const r = s - t.startTime;
827
834
  let l = `[test-variants] tests: ${t.tests} (${ee(r)}), async: ${t.iterationsAsync}`;
828
835
  if (t.prevLogMemory != null) {
829
- const u = Q();
830
- u != null && (l += `, memory: ${be(u, t.prevLogMemory)}`, t.prevLogMemory = u);
836
+ const f = Q();
837
+ f != null && (l += `, memory: ${be(f, t.prevLogMemory)}`, t.prevLogMemory = f);
831
838
  }
832
- return i.func("progress", l), t.prevLogTime = a, !0;
839
+ return i.func("progress", l), t.prevLogTime = s, !0;
833
840
  }
834
841
  function J(e, n) {
835
842
  e.debugMode = !1, n && (e.iterationsAsync += n.iterationsAsync, e.iterations += n.iterationsSync + n.iterationsAsync);
@@ -838,11 +845,11 @@ function X(e) {
838
845
  e.state.debugMode = !0, e.abortControllerParallel.abort(new I());
839
846
  }
840
847
  function ve(e, n) {
841
- const { testRun: t, testOptions: i, state: o } = e, a = o.tests;
848
+ const { testRun: t, testOptions: i, state: o } = e, s = o.tests;
842
849
  o.tests++;
843
850
  try {
844
- const r = t(n, a, i);
845
- if (M(r))
851
+ const r = t(n, s, i);
852
+ if (T(r))
846
853
  return r.then(
847
854
  (l) => {
848
855
  if (!l) {
@@ -851,7 +858,7 @@ function ve(e, n) {
851
858
  }
852
859
  J(o, l);
853
860
  },
854
- (l) => ce(e, n, l, a)
861
+ (l) => ce(e, n, l, s)
855
862
  );
856
863
  if (!r) {
857
864
  X(e);
@@ -859,11 +866,11 @@ function ve(e, n) {
859
866
  }
860
867
  J(o, r);
861
868
  } catch (r) {
862
- return r instanceof I ? void 0 : ce(e, n, r, a);
869
+ return r instanceof I ? void 0 : ce(e, n, r, s);
863
870
  }
864
871
  }
865
872
  function wt(e, n) {
866
- const { pool: t, abortSignal: i, testRun: o, testOptionsParallel: a, state: r } = e;
873
+ const { pool: t, abortSignal: i, testRun: o, testOptionsParallel: s, state: r } = e;
867
874
  if (!t)
868
875
  return;
869
876
  const l = r.tests;
@@ -871,26 +878,26 @@ function wt(e, n) {
871
878
  try {
872
879
  if (i.aborted)
873
880
  return;
874
- let u = o(n, l, a);
875
- if (M(u) && (u = await u), !u) {
881
+ let f = o(n, l, s);
882
+ if (T(f) && (f = await f), !f) {
876
883
  X(e);
877
884
  return;
878
885
  }
879
- J(r, u);
880
- } catch (u) {
881
- if (u instanceof I)
886
+ J(r, f);
887
+ } catch (f) {
888
+ if (f instanceof I)
882
889
  return;
883
- ht(e, n, u, l);
890
+ ht(e, n, f, l);
884
891
  } finally {
885
892
  t.release(1);
886
893
  }
887
894
  })();
888
895
  }
889
896
  function Ee(e) {
890
- const { options: n, state: t } = e, { logOptions: i, timeController: o, GC_Interval: a } = n;
891
- if (!i.progress && !a)
897
+ const { options: n, state: t } = e, { logOptions: i, timeController: o, GC_Interval: s } = n;
898
+ if (!i.progress && !s)
892
899
  return;
893
- St(e);
900
+ xt(e);
894
901
  const r = o.now();
895
902
  if (bt(e, r))
896
903
  return yt(t, r);
@@ -902,114 +909,116 @@ function Z(e) {
902
909
  return e.abortSignal.aborted;
903
910
  }
904
911
  async function W(e, n) {
905
- const { pool: t, state: i, options: o } = e, { parallel: a, logOptions: r } = o;
912
+ const { pool: t, state: i, options: o } = e, { parallel: s, logOptions: r } = o;
906
913
  let l = null;
907
914
  for (; !k(e); ) {
908
- const u = t && !Z(e);
909
- let c = !1;
910
- u && (t.hold(1) || await se({ pool: t, count: 1, hold: !0 }), c = !0);
915
+ const f = t && !Z(e);
916
+ let m = !1;
917
+ f && (t.hold(1) || await se({ pool: t, count: 1, hold: !0 }), m = !0);
911
918
  try {
912
919
  if (n != null ? (l = n, n = null) : e.state.debugMode || (l = e.variantsIterator.next()), l == null)
913
920
  break;
914
- const d = Ee(e);
915
- if (M(d) && await d, k(e))
921
+ const c = Ee(e);
922
+ if (T(c) && await c, k(e))
916
923
  continue;
917
- if (u)
918
- wt(e, l), c = !1;
924
+ if (f)
925
+ wt(e, l), m = !1;
919
926
  else {
920
927
  r.debug && t && Z(e) && r.func(
921
928
  "debug",
922
929
  `[test-variants] parallel aborted, running sequential: tests=${i.tests}`
923
930
  );
924
- const h = ve(e, l);
925
- M(h) && await h;
931
+ const b = ve(e, l);
932
+ T(b) && await b;
926
933
  }
927
934
  } finally {
928
- c && t.release(1);
935
+ m && t.release(1);
929
936
  }
930
937
  }
931
- t && (await se({ pool: t, count: a, hold: !0 }), t.release(a));
938
+ t && (await se({ pool: t, count: s, hold: !0 }), t.release(s));
932
939
  }
933
940
  function Mt(e) {
934
941
  const { pool: n, state: t, options: i } = e, { logOptions: o } = i;
935
942
  if (n)
936
943
  return W(e);
937
- let a = null;
938
- for (; !k(e) && (e.state.debugMode || (a = e.variantsIterator.next()), a != null); ) {
944
+ let s = null;
945
+ for (; !k(e) && (e.state.debugMode || (s = e.variantsIterator.next()), s != null); ) {
939
946
  const r = Ee(e);
940
- if (M(r))
941
- return r.then(() => W(e, a));
947
+ if (T(r))
948
+ return r.then(() => W(e, s));
942
949
  if (k(e))
943
950
  continue;
944
951
  o.debug && Z(e) && o.func(
945
952
  "debug",
946
953
  `[test-variants] parallel aborted, running sequential: tests=${t.tests}`
947
954
  );
948
- const l = ve(e, a);
949
- if (M(l))
955
+ const l = ve(e, s);
956
+ if (T(l))
950
957
  return l.then(() => W(e));
951
958
  }
952
959
  }
953
960
  async function It(e, n, t, i) {
954
961
  const o = pt(i), {
955
- store: a,
962
+ store: s,
956
963
  logOptions: r,
957
964
  abortSignalExternal: l,
958
- findBestError: u,
959
- dontThrowIfError: c,
960
- timeController: d,
961
- parallel: h
962
- } = o, y = new ie(), p = new ie(), b = oe(
965
+ findBestError: f,
966
+ dontThrowIfError: m,
967
+ timeController: c,
968
+ parallel: b
969
+ } = o, y = new ie(), d = new ie(), h = oe(
963
970
  l,
964
971
  y.signal
965
- ), E = oe(
966
- b,
967
- p.signal
968
- ), L = {
969
- abortSignal: b,
970
- timeController: d
971
- }, g = {
972
- abortSignal: E,
973
- timeController: d
972
+ ), v = oe(
973
+ h,
974
+ d.signal
975
+ ), x = {
976
+ abortSignal: h,
977
+ timeController: c
978
+ }, p = {
979
+ abortSignal: v,
980
+ timeController: c
974
981
  };
975
- a && await a.replay({
982
+ s && await s.replay({
976
983
  testRun: e,
977
984
  variantsIterator: n,
978
- testOptions: L,
979
- findBestErrorEnabled: !!u
985
+ testOptions: x,
986
+ findBestErrorEnabled: !!f
980
987
  });
981
- const S = h <= 1 ? null : new Ke(h);
988
+ const w = b <= 1 ? null : new Ke(b);
982
989
  Et(r, t.startMemory);
983
- const V = {
990
+ const A = {
984
991
  options: o,
985
992
  testRun: e,
986
993
  variantsIterator: n,
987
- testOptions: L,
988
- testOptionsParallel: g,
994
+ testOptions: x,
995
+ testOptionsParallel: p,
989
996
  abortControllerGlobal: y,
990
- abortControllerParallel: p,
991
- abortSignal: E,
992
- pool: S,
997
+ abortControllerParallel: d,
998
+ abortSignal: v,
999
+ pool: w,
993
1000
  state: t
994
1001
  };
995
- ye(V);
1002
+ ye(A);
996
1003
  try {
997
- await Mt(V), E.throwIfAborted();
1004
+ await Mt(A), v.throwIfAborted();
998
1005
  } catch (P) {
999
1006
  throw y.abort(new I()), P;
1000
1007
  }
1001
- return b.throwIfAborted(), y.abort(new I()), xt(V), await Y(1), mt(t, n, c);
1008
+ return h.throwIfAborted(), y.abort(new I()), St(A), await Y(1), mt(t, n, m);
1002
1009
  }
1003
1010
  function Nt(e) {
1004
1011
  return function(t) {
1005
1012
  return async function(o) {
1006
- const a = pe(o?.log), r = st(e, {
1013
+ const s = pe(o?.log), r = st(e, {
1014
+ onStart: o?.onStart,
1015
+ onEnd: o?.onEnd,
1007
1016
  onError: o?.onError,
1008
- log: a,
1017
+ log: s,
1009
1018
  pauseDebuggerOnError: o?.pauseDebuggerOnError
1010
- }), l = o?.timeController ?? K, u = Q(), c = nt(l, u), d = o?.onModeChange;
1011
- function h(p) {
1012
- c.pendingModeChange = p, d?.(p);
1019
+ }), l = o?.timeController ?? K, f = Q(), m = nt(l, f), c = o?.onModeChange;
1020
+ function b(d) {
1021
+ m.pendingModeChange = d, c?.(d);
1013
1022
  }
1014
1023
  const y = dt({
1015
1024
  argsTemplates: t,
@@ -1019,12 +1028,12 @@ function Nt(e) {
1019
1028
  limitArgOnError: o?.findBestError?.limitArgOnError,
1020
1029
  includeErrorVariant: o?.findBestError?.includeErrorVariant,
1021
1030
  timeController: l,
1022
- onModeChange: h,
1031
+ onModeChange: b,
1023
1032
  limitCompletionCount: o?.cycles ?? 1,
1024
1033
  limitTests: o?.limitTests,
1025
1034
  limitTime: o?.limitTime
1026
1035
  });
1027
- return It(r, y, c, o);
1036
+ return It(r, y, m, o);
1028
1037
  };
1029
1038
  };
1030
1039
  }