@flemist/test-variants 5.0.8 → 5.0.9

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