@flemist/test-variants 5.0.9 → 5.0.11

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-BdWikiOA.js");exports.createTestVariants=e.createTestVariants;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-6NbYYHA7.js");exports.createTestVariants=e.createTestVariants;
@@ -1,4 +1,4 @@
1
- import { c as r } from "../createTestVariants-BiFu-zG6.mjs";
1
+ import { c as r } from "../createTestVariants-DHWt92RI.mjs";
2
2
  export {
3
3
  r as createTestVariants
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-BdWikiOA.js");exports.createTestVariants=e.createTestVariants;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-6NbYYHA7.js");exports.createTestVariants=e.createTestVariants;
@@ -1,2 +1,2 @@
1
- export { type ErrorEvent, type GenerateErrorVariantFilePathOptions, type GetSeedParams, type LimitArgOnError, type LimitArgOnErrorOptions, type ModeChangeEvent, type ModeConfig, type OnErrorCallback, type OnModeChangeCallback, type ParallelOptions, type SaveErrorVariantsOptions, type TestVariantsBestError, type FindBestErrorOptions, type TestVariantsLogFormat, type TestVariantsLogOptions, type TestVariantsRunOptions, type TestVariantsResult, type TestVariantsState, type TestVariantsTestResult, type TestVariantsSetArgs, } from './test-variants/types';
1
+ export * from './test-variants/types';
2
2
  export { createTestVariants } from './test-variants/createTestVariants';
@@ -1,4 +1,4 @@
1
- import { c as r } from "../createTestVariants-BiFu-zG6.mjs";
1
+ import { c as r } from "../createTestVariants-DHWt92RI.mjs";
2
2
  export {
3
3
  r as createTestVariants
4
4
  };
@@ -1,4 +1,4 @@
1
- "use strict";const Y=require("@flemist/time-controller"),ee=require("@flemist/simple-utils"),S=require("@flemist/async-utils"),z=require("@flemist/abort-controller-fast"),H=require("@flemist/time-limits");function te(){if(typeof process<"u"&&process.memoryUsage)try{return process.memoryUsage.rss()}catch{}if(typeof performance<"u"){const e=performance.memory;if(e)try{return e.usedJSHeapSize}catch{}}return null}const He=1e3,_=[];function Je(e){return ee.formatAny(e,{pretty:!0,maxDepth:5,maxItems:50})}function Xe(...e){const n=e.map(t=>typeof t=="string"?t:Je(t)).join(" ");_.push(n),_.length>He&&_.shift(),console.log(n)}function Ze(){return _.join(`
2
- `)}globalThis.__getStressTestLogLast=Ze;const me=(e,n)=>{Xe(n)},de=e=>ee.formatAny(e,{pretty:!0,maxDepth:20,maxItems:100,maxStringLength:5e3,customToString:n=>{if(typeof n=="function")return`function ${n.name||"anonymous"}()`}}),x={start:!0,progress:5e3,completed:!0,error:!0,modeChange:!0,debug:!1,func:me,format:de},Ke={start:!1,progress:!1,completed:!1,error:!1,modeChange:!1,debug:!1,func:me,format:de};function ge(e){return e===!1?Ke:e===!0||!e?x:{start:e.start??x.start,progress:e.progress??x.progress,completed:e.completed??x.completed,error:e.error??x.error,modeChange:e.modeChange??x.modeChange,debug:e.debug??x.debug,func:e.func??x.func,format:e.format??x.format}}function Qe(e,n){const t=e.now();return{startTime:t,startMemory:n,debugMode:!1,tests:0,iterations:0,iterationsAsync:0,prevLogTime:t,prevLogMemory:n,pendingModeChange:null,prevGcTime:t,prevGcIterations:0,prevGcIterationsAsync:0}}class T extends z.AbortError{}const Ye=50,et=5;function ae(e,n){return typeof e=="number"?{iterationsAsync:0,iterationsSync:e}:e!=null&&typeof e=="object"?e:n?{iterationsAsync:1,iterationsSync:0}:{iterationsAsync:0,iterationsSync:1}}function tt(e,n){const t=n.log,i=n.pauseDebuggerOnError??!0;let o=null,a=0;function r(l,u,f){o==null&&(o={error:l,args:u,tests:f},t.error&&t.func("error",`[test-variants] error variant: ${t.format(u)}
1
+ "use strict";const Y=require("@flemist/time-controller"),ee=require("@flemist/simple-utils"),E=require("@flemist/async-utils"),z=require("@flemist/abort-controller-fast"),H=require("@flemist/time-limits");function te(){if(typeof process<"u"&&process.memoryUsage)try{return process.memoryUsage.rss()}catch{}if(typeof performance<"u"){const e=performance.memory;if(e)try{return e.usedJSHeapSize}catch{}}return null}const He=1e3,_=[];function Je(e){return ee.formatAny(e,{pretty:!0,maxDepth:5,maxItems:50})}function Xe(...e){const n=e.map(t=>typeof t=="string"?t:Je(t)).join(" ");_.push(n),_.length>He&&_.shift(),console.log(n)}function Ze(){return _.join(`
2
+ `)}globalThis.__getStressTestLogLast=Ze;const me=(e,n)=>{Xe(n)},de=e=>ee.formatAny(e,{pretty:!0,maxDepth:20,maxItems:100,maxStringLength:5e3,dontExpandClassInstances:!0,dontExpandFunctions:!0}),S={start:!0,progress:5e3,completed:!0,error:!0,modeChange:!0,debug:!1,func:me,format:de},Ke={start:!1,progress:!1,completed:!1,error:!1,modeChange:!1,debug:!1,func:me,format:de};function ge(e){return e===!1?Ke:e===!0||!e?S:{start:e.start??S.start,progress:e.progress??S.progress,completed:e.completed??S.completed,error:e.error??S.error,modeChange:e.modeChange??S.modeChange,debug:e.debug??S.debug,func:e.func??S.func,format:e.format??S.format}}function Qe(e,n){const t=e.now();return{startTime:t,startMemory:n,debugMode:!1,tests:0,iterations:0,iterationsAsync:0,prevLogTime:t,prevLogMemory:n,pendingModeChange:null,prevGcTime:t,prevGcIterations:0,prevGcIterationsAsync:0}}class I extends z.AbortError{}const Ye=50,et=5;function ae(e,n){return typeof e=="number"?{iterationsAsync:0,iterationsSync:e}:e!=null&&typeof e=="object"?e:n?{iterationsAsync:1,iterationsSync:0}:{iterationsAsync:0,iterationsSync:1}}function tt(e,n){const t=n.log,i=n.pauseDebuggerOnError??!0;let o=null,a=0;function r(l,u,f){o==null&&(o={error:l,args:u,tests:f},t.error&&t.func("error",`[test-variants] error variant: ${t.format(u)}
3
3
  tests: ${f}
4
- ${t.format(l)}`));const m=Date.now();if(i)debugger;if(Date.now()-m>Ye&&a<et){t.func("debug",`[test-variants] debug iteration: ${a}`),a++;return}const y=o;throw o=null,n.onError&&n.onError(y),y.error}return function(u,f,m){try{const h=e(u,m);return S.isPromiseLike(h)?h.then(y=>ae(y,!0),y=>r(y,u,f)):ae(h,!1)}catch(h){return h instanceof T?void 0:r(h,u,f)}}}function k(e,n,t){for(let i=0,o=e.length;i<o;i++)if(t?t(e[i],n):e[i]===n)return i;return-1}function le(e,n,t,i){const o=Object.keys(e.templates),a={},r=[],l=[],u=[],f=o.length;for(let m=0;m<f;m++){const h=o[m];a[h]=void 0,r.push(-1),l.push(void 0),u.push(null)}return{args:a,argsNames:o,indexes:r,argValues:l,argLimits:u,attempts:0,templates:e,limitArgOnError:t,equals:n,includeErrorVariant:i??!1}}function L(e,n){const t=e.templates.templates[n],i=e.templates.extra[n];let o;if(typeof t=="function"?o=t(e.args):o=t,i==null)return o;let a=null;const r=i.length;for(let l=0;l<r;l++){const u=i[l];k(o,u,e.equals)<0&&(a==null?a=[...o,u]:a.push(u))}return a??o}function M(e,n,t){const i=e.argValues[n].length;if(i===0)return-1;const o=e.argLimits[n];if(o==null)return i-1;let a=e.limitArgOnError;if(typeof a=="function"){const r=e.argsNames[n];a=a({name:r,values:e.argValues[n],maxValueIndex:o})}return!t||a?Math.min(o,i-1):i-1}function V(e){const n=e.indexes.length;for(let t=0;t<n;t++){const i=e.argLimits[t];if(i==null)return!1;const o=e.indexes[t];if(o>i)return!0;if(o<i)return!1}return!e.includeErrorVariant}function C(e){const n=e.indexes.length;for(let t=0;t<n;t++)e.indexes[t]=-1,e.argValues[t]=void 0,e.args[e.argsNames[t]]=void 0}function pe(e){let n=!1,t=!0;const i=e.indexes.length;let o=i,a=!1,r=0;for(;r<i;r++){const l=e.argValues[r]==null;(l||a)&&(l&&(n=!0),e.argValues[r]=L(e,e.argsNames[r]));const u=M(e,r,r>o);if(u<0){t=!1,e.indexes[r]=-1;break}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)}if(V(e))return C(e),!1;if(n&&t)return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let l=r>o;const u=M(e,r,l),f=e.indexes[r]+1;if(f<=u){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(l=!0);for(let m=r+1;m<i;m++)e.args[e.argsNames[m]]=void 0;for(r++;r<i;r++){e.argValues[r]=L(e,e.argsNames[r]);const m=M(e,r,l);if(m<0)break;e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0],m>0&&(l=!0)}if(r>=i)return V(e)?(C(e),!1):!0}}return C(e),!1}function J(e){V(e)&&C(e);let n=!1,t=!0;const i=e.indexes.length;let o=i,a=!1,r=0;for(;r<i;r++){const l=e.argValues[r]==null;(l||a)&&(l&&(n=!0),e.argValues[r]=L(e,e.argsNames[r]));const u=M(e,r,r>o);if(u<0){t=!1,e.indexes[r]=-1;break}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)}if((n||a)&&t&&!V(e))return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let l=r>o;const u=M(e,r,l);let f=e.indexes[r]-1;if(f>u&&(f=u),f>=0){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(l=!0);for(let m=r+1;m<i;m++)e.args[e.argsNames[m]]=void 0;for(r++;r<i;r++){e.argValues[r]=L(e,e.argsNames[r]);const m=M(e,r,l);if(m<0)break;e.indexes[r]=m,e.args[e.argsNames[r]]=e.argValues[r][m],m>0&&(l=!0)}if(r>=i)return!0}}return C(e),!1}function rt(e,n){C(e);const t=e.argsNames,i=t.length;let o=!1;for(let a=0;a<i;a++){const r=t[a],l=n[r];if(l===void 0)return null;e.argValues[a]=L(e,r);const u=M(e,a,o);if(u<0)return null;const f=k(e.argValues[a],l,e.equals);if(f<0||f>u)return null;e.indexes[a]=f,e.args[e.argsNames[a]]=e.argValues[a][f],e.indexes[a]<u&&(o=!0)}return V(e)?null:e.indexes.slice()}function nt(e){const n=e.indexes.length;if(n===0)return!1;let t=!1;for(let i=0;i<n;i++){e.argValues[i]=L(e,e.argsNames[i]);const o=M(e,i,t);if(o<0)return Math.random()<.5?pe(e):J(e);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)}return V(e)?J(e):!0}function D(e){return e.mode==="forward"||e.mode==="backward"}function ot(e,n,t,i){const o=n[t],a=e.templates[t];if(typeof a!="function"){if(k(a,o,i)>=0)return;a.push(o);return}const r=e.extra[t];if(r==null){e.extra[t]=[o];return}k(r,o,i)>=0||r.push(o)}function it(e,n,t){for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)){if(i==="seed")continue;ot(e,n,i,t)}}function ue(e,n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(t==="seed")continue;if(!e[t])return!1}return!0}const st=[{mode:"forward"}];function at(e){const{argsTemplates:n,equals:t,limitArgOnError:i,includeErrorVariant:o,getSeed:a,iterationModes:r,onModeChange:l,limitCompletionCount:u,limitTests:f,limitTime:m}=e,h=e.timeController??Y.timeControllerDefault,y={templates:ee.deepCloneJsonLike(n),extra:{}},p=r==null||r.length===0?st:r,b=[];let E=null,O=null,g=0,w=0,I=!1,N=0;function $(){I||(I=!0,N=h.now(),Se(),g=0,oe(),xe())}function Se(){for(let s=0,c=p.length;s<c;s++)b.push(Ee())}function Ee(){return{navigationState:le(y,t??null,i??null,o??null),cycleCount:0,completedCount:0,testsInLastTurn:0,tryNextVariantAttempts:0,startTime:null}}function xe(){E=le(y,t??null,!1,!1)}function oe(){l?.({mode:p[g],modeIndex:g,tests:w})}function we(s){$(),ue(y.templates,s)&&it(y,s,t)}function ie(s,c){return $(),ue(y.templates,s)?(E.limitArgOnError=c?.limitArg??i??null,E.includeErrorVariant=c?.includeLimit??o??!1,rt(E,s)):null}function Me(s){const c=s?.args;if(c==null)return;$();const d=ie(c);if(d!=null){O={args:c,error:s?.error,tests:s?.tests??w},E.argLimits=d;for(let v=0,q=b.length;v<q;v++){const j=b[v].navigationState;j.argLimits=d}}}function Te(){return $(),Ve()}function Ve(){for(;;){if(!Ie())return null;for(;;){const s=De();if(s!=null)return b[g].testsInLastTurn++,w++,s;if(Ne()){if(!$e())return null;qe();break}}}}function Ie(){return!(Ae()||Ce()||G()&&(Le()||!Oe())||!Pe())}function Ae(){return f!=null&&w>=f}function Ce(){return m!=null&&h.now()-N>=m}function Le(){if(!G())throw new Error("Unexpected behavior");return u!=null&&u<=0}function Oe(){if(!G())throw new Error("Unexpected behavior");for(let s=0,c=p.length;s<c;s++)if(A(p[s])&&R(s))return!0;return!1}function Pe(){for(let s=0,c=p.length;s<c;s++)if(R(s))return!0;return!1}function Ne(){g++;const s=g>=p.length;return s&&(g=0),oe(),s}function $e(){if(G()){const s=Ge();if(u!=null&&s>=u)return!1}return!0}function G(){for(let s=0,c=p.length;s<c;s++)if(D(p[s]))return!0;return!1}function Ge(){let s=!1,c=1/0;for(let d=0,v=b.length;d<v;d++){const q=b[d],j=p[d];D(j)&&(s=!0,R(d)&&q.completedCount<c&&(c=q.completedCount))}if(!s)throw new Error("Unexpected behavior");return c}function R(s){const c=p[s],d=b[s];return c.limitTests!=null&&c.limitTests<=0||A(c)&&(c.cycles!=null&&c.cycles<=0||c.attemptsPerVariant!=null&&c.attemptsPerVariant<=0)?!1:d.tryNextVariantAttempts<2}function qe(){g=0;for(let s=0,c=b.length;s<c;s++){const d=b[s];d.testsInLastTurn=0,d.startTime=null}}function De(){let s=0;for(;s<2;){if(!_e())return null;const c=Fe();if(c!=null)return c;if(A(p[g])&&Re())return null;s++}return null}function _e(){const s=p[g];return!(ke()||Ue()||A(s)&&!Be(g))}function ke(){const s=p[g],c=b[g];return s.limitTests!=null&&c.testsInLastTurn>=s.limitTests}function Ue(){const s=p[g],c=b[g];return s.limitTime!=null&&c.startTime!=null&&h.now()-c.startTime>=s.limitTime}function A(s){return D(s)}function Be(s){const c=p[s],d=b[s];if(!A(c))throw new Error("Unexpected behavior");return d.cycleCount<(c.cycles??1)}function Re(){const s=p[g],c=b[g];if(!A(s))throw new Error("Unexpected behavior");return c.cycleCount++,c.cycleCount>=(s.cycles??1)?(c.cycleCount=0,c.completedCount++,!0):!1}function Fe(){const s=p[g],c=b[g],d=c.navigationState;if(P(s)){if(F())return null;const v=je();if(v!=null)return c.startTime==null&&(c.startTime=h.now()),v}return ze()?(c.tryNextVariantAttempts=0,P(s)&&We(),c.startTime==null&&(c.startTime=h.now()),se(d.args)):(c.tryNextVariantAttempts++,null)}function je(){const s=p[g],d=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(F())throw new Error("Unexpected behavior");const v=s.attemptsPerVariant??1;return d.attempts>0&&d.attempts<v?V(d)?null:(d.attempts++,se(d.args)):null}function We(){const s=p[g],d=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(F())throw new Error("Unexpected behavior");d.attempts=1}function P(s){return D(s)}function F(){const s=p[g];if(!P(s))throw new Error("Unexpected behavior");return(s.attemptsPerVariant??1)<=0}function ze(){const s=p[g],d=b[g].navigationState;switch(s.mode){case"forward":return pe(d);case"backward":return J(d);case"random":return nt(d);default:throw new Error(`Unknown mode: ${s.mode}`)}}function se(s){const c={...s};return a!=null&&(c.seed=a({tests:w})),c}return{get limit(){return O},get modeIndex(){return g},get modeConfigs(){return p},get modeStates(){return b},get tests(){return w},calcIndexes:ie,extendTemplates:we,addLimit:Me,next:Te}}function re(e){if(e==null||e<=0)throw new Error(`Iterations = ${e}`);e--;const n=S.waitMicrotasks().then(()=>e);return e<=0?n:n.then(re)}function lt(e,n,t){const i=n.limit?{error:n.limit.error,args:n.limit.args,tests:n.limit.tests}:null;if(i&&!t)throw i.error;return{iterations:e.iterations,bestError:i}}const ce=2**31;function ut(e){if(e==null)return{parallel:1,sequentialOnError:!1};if(typeof e=="boolean")return{parallel:e?ce:1,sequentialOnError:!1};if(typeof e=="number")return{parallel:e>0?e:1,sequentialOnError:!1};const n=e.count;let t=1;return n===!0?t=ce:typeof n=="number"&&n>0&&(t=n),{parallel:t,sequentialOnError:e.sequentialOnError??!1}}function ct(e){const n=e?.saveErrorVariants,t=n&&e.createSaveErrorVariantsStore?e.createSaveErrorVariantsStore(n):null,i=e?.findBestError,{parallel:o,sequentialOnError:a}=ut(e?.parallel);return{store:t,GC_Iterations:e?.GC_Iterations??1e6,GC_IterationsAsync:e?.GC_IterationsAsync??1e4,GC_Interval:e?.GC_Interval??1e3,logOptions:ge(e?.log),abortSignalExternal:e?.abortSignal,findBestError:i,dontThrowIfError:i?.dontThrowIfError,timeController:e?.timeController??Y.timeControllerDefault,parallel:o,sequentialOnError:a}}function U(e,n,t){const{options:i,variantsIterator:o}=e,a=o.limit?.args??n;if(!i.store)return;const r=i.store.save(a);if(t)return r}function ft(e,n,t,i){const{abortControllerParallel:o,state:a,options:r}=e,{logOptions:l}=r;if(e.options.findBestError)e.variantsIterator.addLimit({args:n,error:t,tests:i}),a.debugMode=!1,U(e,n,!1),r.sequentialOnError&&!o.signal.aborted?(l.debug&&l.func("debug","[test-variants] sequentialOnError: aborting parallel, switching to sequential"),o.abort(new T)):l.debug&&l.func("debug","[test-variants] parallel error in findBestError mode, continuing with new limits");else{if(o.signal.aborted)return;U(e,n,!1),o.abort(t)}}function fe(e,n,t,i){const{state:o}=e;if(e.options.findBestError){e.variantsIterator.addLimit({args:n,error:t,tests:i});const r=U(e,n,!0);if(r)return r.then(()=>{o.debugMode=!1});o.debugMode=!1;return}const a=U(e,n,!0);if(a)return a.then(()=>{throw t});throw t}function mt(e,n){const{GC_Iterations:t,GC_IterationsAsync:i,GC_Interval:o}=e.options;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}async function dt(e,n){e.prevGcIterations=e.iterations,e.prevGcIterationsAsync=e.iterationsAsync,e.prevGcTime=n,await re(1)}function ne(e){const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const t=n/60;return t<60?`${t.toFixed(1)}m`:`${(t/60).toFixed(1)}h`}function X(e){const n=e/1073741824;if(n>=1)return n>=10?`${Math.round(n)}GB`:`${n.toFixed(1)}GB`;const t=e/(1024*1024);return t>=10?`${Math.round(t)}MB`:`${t.toFixed(1)}MB`}function gt(e,n){if(!e)return`mode[${n}]: null`;let t=`mode[${n}]: ${e.mode}`;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=${ne(e.limitTime)}`),e.limitTests!=null&&(t+=`, limitTests=${e.limitTests}`),t}function he(e,n){const t=e-n,i=t>=0?"+":"";return`${X(e)} (${i}${X(t)})`}function pt(e,n){if(!e.start)return;let t="[test-variants] start";n!=null&&(t+=`, memory: ${X(n)}`),e.func("start",t)}function ht(e){const{options:n,state:t}=e,{logOptions:i,timeController:o}=n;if(!i.completed)return;const a=o.now()-t.startTime;let r=`[test-variants] end, tests: ${t.tests} (${ne(a)}), async: ${t.iterationsAsync}`;if(t.startMemory!=null){const l=te();l!=null&&(r+=`, memory: ${he(l,t.startMemory)}`)}i.func("completed",r)}function be(e){const{options:n,state:t}=e,{logOptions:i}=n,o=t.pendingModeChange;!i.modeChange||o==null||(i.func("modeChange",`[test-variants] ${gt(o.mode,o.modeIndex)}`),t.pendingModeChange=null)}function bt(e){const{options:n,state:t}=e,{logOptions:i,timeController:o}=n,a=o.now();if(!i.progress||a-t.prevLogTime<i.progress)return!1;be(e);const r=a-t.startTime;let l=`[test-variants] tests: ${t.tests} (${ne(r)}), async: ${t.iterationsAsync}`;if(t.prevLogMemory!=null){const u=te();u!=null&&(l+=`, memory: ${he(u,t.prevLogMemory)}`,t.prevLogMemory=u)}return i.func("progress",l),t.prevLogTime=a,!0}function Z(e,n){e.debugMode=!1,n&&(e.iterationsAsync+=n.iterationsAsync,e.iterations+=n.iterationsSync+n.iterationsAsync)}function K(e){e.state.debugMode=!0,e.abortControllerParallel.abort(new T)}function ye(e,n){const{testRun:t,testOptions:i,state:o}=e,a=o.tests;o.tests++;try{const r=t(n,a,i);if(S.isPromiseLike(r))return r.then(l=>{if(!l){K(e);return}Z(o,l)},l=>fe(e,n,l,a));if(!r){K(e);return}Z(o,r)}catch(r){return r instanceof T?void 0:fe(e,n,r,a)}}function yt(e,n){const{pool:t,abortSignal:i,testRun:o,testOptionsParallel:a,state:r}=e;if(!t)return;const l=r.tests;r.tests++,(async()=>{try{if(i.aborted)return;let u=o(n,l,a);if(S.isPromiseLike(u)&&(u=await u),!u){K(e);return}Z(r,u)}catch(u){if(u instanceof T)return;ft(e,n,u,l)}finally{t.release(1)}})()}function ve(e){const{options:n,state:t}=e,{logOptions:i,timeController:o,GC_Interval:a}=n;if(!i.progress&&!a)return;bt(e);const r=o.now();if(mt(e,r))return dt(t,r)}function B(e){return e.options.abortSignalExternal?.aborted??!1}function Q(e){return e.abortSignal.aborted}async function W(e,n){const{pool:t,state:i,options:o}=e,{parallel:a,logOptions:r}=o;let l=null;for(;!B(e);){const u=t&&!Q(e);let f=!1;u&&(t.hold(1)||await H.poolWait({pool:t,count:1,hold:!0}),f=!0);try{if(n!=null?(l=n,n=null):e.state.debugMode||(l=e.variantsIterator.next()),l==null)break;const m=ve(e);if(S.isPromiseLike(m)&&await m,B(e))continue;if(u)yt(e,l),f=!1;else{r.debug&&t&&Q(e)&&r.func("debug",`[test-variants] parallel aborted, running sequential: tests=${i.tests}`);const h=ye(e,l);S.isPromiseLike(h)&&await h}}finally{f&&t.release(1)}}t&&(await H.poolWait({pool:t,count:a,hold:!0}),t.release(a))}function vt(e){const{pool:n,state:t,options:i}=e,{logOptions:o}=i;if(n)return W(e);let a=null;for(;!B(e)&&(e.state.debugMode||(a=e.variantsIterator.next()),a!=null);){const r=ve(e);if(S.isPromiseLike(r))return r.then(()=>W(e,a));if(B(e))continue;o.debug&&Q(e)&&o.func("debug",`[test-variants] parallel aborted, running sequential: tests=${t.tests}`);const l=ye(e,a);if(S.isPromiseLike(l))return l.then(()=>W(e))}}async function St(e,n,t,i){const o=ct(i),{store:a,logOptions:r,abortSignalExternal:l,findBestError:u,dontThrowIfError:f,timeController:m,parallel:h}=o,y=new z.AbortControllerFast,p=new z.AbortControllerFast,b=S.combineAbortSignals(l,y.signal),E=S.combineAbortSignals(b,p.signal),O={abortSignal:b,timeController:m},g={abortSignal:E,timeController:m};a&&await a.replay({testRun:e,variantsIterator:n,testOptions:O,findBestErrorEnabled:!!u});const w=h<=1?null:new H.Pool(h);pt(r,t.startMemory);const I={options:o,testRun:e,variantsIterator:n,testOptions:O,testOptionsParallel:g,abortControllerGlobal:y,abortControllerParallel:p,abortSignal:E,pool:w,state:t};be(I);try{await vt(I),E.throwIfAborted()}catch(N){throw y.abort(new T),N}return b.throwIfAborted(),y.abort(new T),ht(I),await re(1),lt(t,n,f)}function Et(e){return function(t){return async function(o){const a=ge(o?.log),r=tt(e,{onError:o?.onError,log:a,pauseDebuggerOnError:o?.pauseDebuggerOnError}),l=o?.timeController??Y.timeControllerDefault,u=te(),f=Qe(l,u),m=o?.onModeChange;function h(p){f.pendingModeChange=p,m?.(p)}const y=at({argsTemplates:t,getSeed:o?.getSeed,iterationModes:o?.iterationModes,equals:o?.findBestError?.equals,limitArgOnError:o?.findBestError?.limitArgOnError,includeErrorVariant:o?.findBestError?.includeErrorVariant,timeController:l,onModeChange:h,limitCompletionCount:o?.cycles??1,limitTests:o?.limitTests,limitTime:o?.limitTime});return St(r,y,f,o)}}}exports.createTestVariants=Et;
4
+ ${t.format(l)}`));const m=Date.now();if(i)debugger;if(Date.now()-m>Ye&&a<et){t.func("debug",`[test-variants] debug iteration: ${a}`),a++;return}const y=o;throw o=null,n.onError&&n.onError(y),y.error}return function(u,f,m){try{const h=e(u,m);return E.isPromiseLike(h)?h.then(y=>ae(y,!0),y=>r(y,u,f)):ae(h,!1)}catch(h){return h instanceof I?void 0:r(h,u,f)}}}function k(e,n,t){for(let i=0,o=e.length;i<o;i++)if(t?t(e[i],n):e[i]===n)return i;return-1}function le(e,n,t,i){const o=Object.keys(e.templates),a={},r=[],l=[],u=[],f=o.length;for(let m=0;m<f;m++){const h=o[m];a[h]=void 0,r.push(-1),l.push(void 0),u.push(null)}return{args:a,argsNames:o,indexes:r,argValues:l,argLimits:u,attempts:0,templates:e,limitArgOnError:t,equals:n,includeErrorVariant:i??!1}}function L(e,n){const t=e.templates.templates[n],i=e.templates.extra[n];let o;if(typeof t=="function"?o=t(e.args):o=t,i==null)return o;let a=null;const r=i.length;for(let l=0;l<r;l++){const u=i[l];k(o,u,e.equals)<0&&(a==null?a=[...o,u]:a.push(u))}return a??o}function M(e,n,t){const i=e.argValues[n].length;if(i===0)return-1;const o=e.argLimits[n];if(o==null)return i-1;let a=e.limitArgOnError;if(typeof a=="function"){const r=e.argsNames[n];a=a({name:r,values:e.argValues[n],maxValueIndex:o})}return!t||a?Math.min(o,i-1):i-1}function T(e){const n=e.indexes.length;for(let t=0;t<n;t++){const i=e.argLimits[t];if(i==null)return!1;const o=e.indexes[t];if(o>i)return!0;if(o<i)return!1}return!e.includeErrorVariant}function C(e){const n=e.indexes.length;for(let t=0;t<n;t++)e.indexes[t]=-1,e.argValues[t]=void 0,e.args[e.argsNames[t]]=void 0}function pe(e){let n=!1,t=!0;const i=e.indexes.length;let o=i,a=!1,r=0;for(;r<i;r++){const l=e.argValues[r]==null;(l||a)&&(l&&(n=!0),e.argValues[r]=L(e,e.argsNames[r]));const u=M(e,r,r>o);if(u<0){t=!1,e.indexes[r]=-1;break}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)}if(T(e))return C(e),!1;if(n&&t)return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let l=r>o;const u=M(e,r,l),f=e.indexes[r]+1;if(f<=u){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(l=!0);for(let m=r+1;m<i;m++)e.args[e.argsNames[m]]=void 0;for(r++;r<i;r++){e.argValues[r]=L(e,e.argsNames[r]);const m=M(e,r,l);if(m<0)break;e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0],m>0&&(l=!0)}if(r>=i)return T(e)?(C(e),!1):!0}}return C(e),!1}function J(e){T(e)&&C(e);let n=!1,t=!0;const i=e.indexes.length;let o=i,a=!1,r=0;for(;r<i;r++){const l=e.argValues[r]==null;(l||a)&&(l&&(n=!0),e.argValues[r]=L(e,e.argsNames[r]));const u=M(e,r,r>o);if(u<0){t=!1,e.indexes[r]=-1;break}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)}if((n||a)&&t&&!T(e))return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let l=r>o;const u=M(e,r,l);let f=e.indexes[r]-1;if(f>u&&(f=u),f>=0){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(l=!0);for(let m=r+1;m<i;m++)e.args[e.argsNames[m]]=void 0;for(r++;r<i;r++){e.argValues[r]=L(e,e.argsNames[r]);const m=M(e,r,l);if(m<0)break;e.indexes[r]=m,e.args[e.argsNames[r]]=e.argValues[r][m],m>0&&(l=!0)}if(r>=i)return!0}}return C(e),!1}function rt(e,n){C(e);const t=e.argsNames,i=t.length;let o=!1;for(let a=0;a<i;a++){const r=t[a],l=n[r];if(l===void 0)return null;e.argValues[a]=L(e,r);const u=M(e,a,o);if(u<0)return null;const f=k(e.argValues[a],l,e.equals);if(f<0||f>u)return null;e.indexes[a]=f,e.args[e.argsNames[a]]=e.argValues[a][f],e.indexes[a]<u&&(o=!0)}return T(e)?null:e.indexes.slice()}function nt(e){const n=e.indexes.length;if(n===0)return!1;let t=!1;for(let i=0;i<n;i++){e.argValues[i]=L(e,e.argsNames[i]);const o=M(e,i,t);if(o<0)return Math.random()<.5?pe(e):J(e);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)}return T(e)?J(e):!0}function D(e){return e.mode==="forward"||e.mode==="backward"}function ot(e,n,t,i){const o=n[t],a=e.templates[t];if(typeof a!="function"){if(k(a,o,i)>=0)return;a.push(o);return}const r=e.extra[t];if(r==null){e.extra[t]=[o];return}k(r,o,i)>=0||r.push(o)}function it(e,n,t){for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)){if(i==="seed")continue;ot(e,n,i,t)}}function ue(e,n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(t==="seed")continue;if(!e[t])return!1}return!0}const st=[{mode:"forward"}];function at(e){const{argsTemplates:n,equals:t,limitArgOnError:i,includeErrorVariant:o,getSeed:a,iterationModes:r,onModeChange:l,limitCompletionCount:u,limitTests:f,limitTime:m}=e,h=e.timeController??Y.timeControllerDefault,y={templates:ee.deepCloneJsonLike(n),extra:{}},p=r==null||r.length===0?st:r,b=[];let x=null,O=null,g=0,w=0,V=!1,N=0;function $(){V||(V=!0,N=h.now(),Ee(),g=0,oe(),Se())}function Ee(){for(let s=0,c=p.length;s<c;s++)b.push(xe())}function xe(){return{navigationState:le(y,t??null,i??null,o??null),cycleCount:0,completedCount:0,testsInLastTurn:0,tryNextVariantAttempts:0,startTime:null}}function Se(){x=le(y,t??null,!1,!1)}function oe(){l?.({mode:p[g],modeIndex:g,tests:w})}function we(s){$(),ue(y.templates,s)&&it(y,s,t)}function ie(s,c){return $(),ue(y.templates,s)?(x.limitArgOnError=c?.limitArg??i??null,x.includeErrorVariant=c?.includeLimit??o??!1,rt(x,s)):null}function Me(s){const c=s?.args;if(c==null)return;$();const d=ie(c);if(d!=null){O={args:c,error:s?.error,tests:s?.tests??w},x.argLimits=d;for(let v=0,q=b.length;v<q;v++){const j=b[v].navigationState;j.argLimits=d}}}function Ie(){return $(),Te()}function Te(){for(;;){if(!Ve())return null;for(;;){const s=De();if(s!=null)return b[g].testsInLastTurn++,w++,s;if(Ne()){if(!$e())return null;qe();break}}}}function Ve(){return!(Ae()||Ce()||G()&&(Le()||!Oe())||!Pe())}function Ae(){return f!=null&&w>=f}function Ce(){return m!=null&&h.now()-N>=m}function Le(){if(!G())throw new Error("Unexpected behavior");return u!=null&&u<=0}function Oe(){if(!G())throw new Error("Unexpected behavior");for(let s=0,c=p.length;s<c;s++)if(A(p[s])&&R(s))return!0;return!1}function Pe(){for(let s=0,c=p.length;s<c;s++)if(R(s))return!0;return!1}function Ne(){g++;const s=g>=p.length;return s&&(g=0),oe(),s}function $e(){if(G()){const s=Ge();if(u!=null&&s>=u)return!1}return!0}function G(){for(let s=0,c=p.length;s<c;s++)if(D(p[s]))return!0;return!1}function Ge(){let s=!1,c=1/0;for(let d=0,v=b.length;d<v;d++){const q=b[d],j=p[d];D(j)&&(s=!0,R(d)&&q.completedCount<c&&(c=q.completedCount))}if(!s)throw new Error("Unexpected behavior");return c}function R(s){const c=p[s],d=b[s];return c.limitTests!=null&&c.limitTests<=0||A(c)&&(c.cycles!=null&&c.cycles<=0||c.attemptsPerVariant!=null&&c.attemptsPerVariant<=0)?!1:d.tryNextVariantAttempts<2}function qe(){g=0;for(let s=0,c=b.length;s<c;s++){const d=b[s];d.testsInLastTurn=0,d.startTime=null}}function De(){let s=0;for(;s<2;){if(!_e())return null;const c=Fe();if(c!=null)return c;if(A(p[g])&&Re())return null;s++}return null}function _e(){const s=p[g];return!(ke()||Ue()||A(s)&&!Be(g))}function ke(){const s=p[g],c=b[g];return s.limitTests!=null&&c.testsInLastTurn>=s.limitTests}function Ue(){const s=p[g],c=b[g];return s.limitTime!=null&&c.startTime!=null&&h.now()-c.startTime>=s.limitTime}function A(s){return D(s)}function Be(s){const c=p[s],d=b[s];if(!A(c))throw new Error("Unexpected behavior");return d.cycleCount<(c.cycles??1)}function Re(){const s=p[g],c=b[g];if(!A(s))throw new Error("Unexpected behavior");return c.cycleCount++,c.cycleCount>=(s.cycles??1)?(c.cycleCount=0,c.completedCount++,!0):!1}function Fe(){const s=p[g],c=b[g],d=c.navigationState;if(P(s)){if(F())return null;const v=je();if(v!=null)return c.startTime==null&&(c.startTime=h.now()),v}return ze()?(c.tryNextVariantAttempts=0,P(s)&&We(),c.startTime==null&&(c.startTime=h.now()),se(d.args)):(c.tryNextVariantAttempts++,null)}function je(){const s=p[g],d=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(F())throw new Error("Unexpected behavior");const v=s.attemptsPerVariant??1;return d.attempts>0&&d.attempts<v?T(d)?null:(d.attempts++,se(d.args)):null}function We(){const s=p[g],d=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(F())throw new Error("Unexpected behavior");d.attempts=1}function P(s){return D(s)}function F(){const s=p[g];if(!P(s))throw new Error("Unexpected behavior");return(s.attemptsPerVariant??1)<=0}function ze(){const s=p[g],d=b[g].navigationState;switch(s.mode){case"forward":return pe(d);case"backward":return J(d);case"random":return nt(d);default:throw new Error(`Unknown mode: ${s.mode}`)}}function se(s){const c={...s};return a!=null&&(c.seed=a({tests:w})),c}return{get limit(){return O},get modeIndex(){return g},get modeConfigs(){return p},get modeStates(){return b},get tests(){return w},calcIndexes:ie,extendTemplates:we,addLimit:Me,next:Ie}}function re(e){if(e==null||e<=0)throw new Error(`Iterations = ${e}`);e--;const n=E.waitMicrotasks().then(()=>e);return e<=0?n:n.then(re)}function lt(e,n,t){const i=n.limit?{error:n.limit.error,args:n.limit.args,tests:n.limit.tests}:null;if(i&&!t)throw i.error;return{iterations:e.iterations,bestError:i}}const ce=2**31;function ut(e){if(e==null)return{parallel:1,sequentialOnError:!1};if(typeof e=="boolean")return{parallel:e?ce:1,sequentialOnError:!1};if(typeof e=="number")return{parallel:e>0?e:1,sequentialOnError:!1};const n=e.count;let t=1;return n===!0?t=ce:typeof n=="number"&&n>0&&(t=n),{parallel:t,sequentialOnError:e.sequentialOnError??!1}}function ct(e){const n=e?.saveErrorVariants,t=n&&e.createSaveErrorVariantsStore?e.createSaveErrorVariantsStore(n):null,i=e?.findBestError,{parallel:o,sequentialOnError:a}=ut(e?.parallel);return{store:t,GC_Iterations:e?.GC_Iterations??1e6,GC_IterationsAsync:e?.GC_IterationsAsync??1e4,GC_Interval:e?.GC_Interval??1e3,logOptions:ge(e?.log),abortSignalExternal:e?.abortSignal,findBestError:i,dontThrowIfError:i?.dontThrowIfError,timeController:e?.timeController??Y.timeControllerDefault,parallel:o,sequentialOnError:a}}function U(e,n,t){const{options:i,variantsIterator:o}=e,a=o.limit?.args??n;if(!i.store)return;const r=i.store.save(a);if(t)return r}function ft(e,n,t,i){const{abortControllerParallel:o,state:a,options:r}=e,{logOptions:l}=r;if(e.options.findBestError)e.variantsIterator.addLimit({args:n,error:t,tests:i}),a.debugMode=!1,U(e,n,!1),r.sequentialOnError&&!o.signal.aborted?(l.debug&&l.func("debug","[test-variants] sequentialOnError: aborting parallel, switching to sequential"),o.abort(new I)):l.debug&&l.func("debug","[test-variants] parallel error in findBestError mode, continuing with new limits");else{if(o.signal.aborted)return;U(e,n,!1),o.abort(t)}}function fe(e,n,t,i){const{state:o}=e;if(e.options.findBestError){e.variantsIterator.addLimit({args:n,error:t,tests:i});const r=U(e,n,!0);if(r)return r.then(()=>{o.debugMode=!1});o.debugMode=!1;return}const a=U(e,n,!0);if(a)return a.then(()=>{throw t});throw t}function mt(e,n){const{GC_Iterations:t,GC_IterationsAsync:i,GC_Interval:o}=e.options;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}async function dt(e,n){e.prevGcIterations=e.iterations,e.prevGcIterationsAsync=e.iterationsAsync,e.prevGcTime=n,await re(1)}function ne(e){const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const t=n/60;return t<60?`${t.toFixed(1)}m`:`${(t/60).toFixed(1)}h`}function X(e){const n=e/1073741824;if(n>=1)return n>=10?`${Math.round(n)}GB`:`${n.toFixed(1)}GB`;const t=e/(1024*1024);return t>=10?`${Math.round(t)}MB`:`${t.toFixed(1)}MB`}function gt(e,n){if(!e)return`mode[${n}]: null`;let t=`mode[${n}]: ${e.mode}`;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=${ne(e.limitTime)}`),e.limitTests!=null&&(t+=`, limitTests=${e.limitTests}`),t}function he(e,n){const t=e-n,i=t>=0?"+":"";return`${X(e)} (${i}${X(t)})`}function pt(e,n){if(!e.start)return;let t="[test-variants] start";n!=null&&(t+=`, memory: ${X(n)}`),e.func("start",t)}function ht(e){const{options:n,state:t}=e,{logOptions:i,timeController:o}=n;if(!i.completed)return;const a=o.now()-t.startTime;let r=`[test-variants] end, tests: ${t.tests} (${ne(a)}), async: ${t.iterationsAsync}`;if(t.startMemory!=null){const l=te();l!=null&&(r+=`, memory: ${he(l,t.startMemory)}`)}i.func("completed",r)}function be(e){const{options:n,state:t}=e,{logOptions:i}=n,o=t.pendingModeChange;!i.modeChange||o==null||(i.func("modeChange",`[test-variants] ${gt(o.mode,o.modeIndex)}`),t.pendingModeChange=null)}function bt(e){const{options:n,state:t}=e,{logOptions:i,timeController:o}=n,a=o.now();if(!i.progress||a-t.prevLogTime<i.progress)return!1;be(e);const r=a-t.startTime;let l=`[test-variants] tests: ${t.tests} (${ne(r)}), async: ${t.iterationsAsync}`;if(t.prevLogMemory!=null){const u=te();u!=null&&(l+=`, memory: ${he(u,t.prevLogMemory)}`,t.prevLogMemory=u)}return i.func("progress",l),t.prevLogTime=a,!0}function Z(e,n){e.debugMode=!1,n&&(e.iterationsAsync+=n.iterationsAsync,e.iterations+=n.iterationsSync+n.iterationsAsync)}function K(e){e.state.debugMode=!0,e.abortControllerParallel.abort(new I)}function ye(e,n){const{testRun:t,testOptions:i,state:o}=e,a=o.tests;o.tests++;try{const r=t(n,a,i);if(E.isPromiseLike(r))return r.then(l=>{if(!l){K(e);return}Z(o,l)},l=>fe(e,n,l,a));if(!r){K(e);return}Z(o,r)}catch(r){return r instanceof I?void 0:fe(e,n,r,a)}}function yt(e,n){const{pool:t,abortSignal:i,testRun:o,testOptionsParallel:a,state:r}=e;if(!t)return;const l=r.tests;r.tests++,(async()=>{try{if(i.aborted)return;let u=o(n,l,a);if(E.isPromiseLike(u)&&(u=await u),!u){K(e);return}Z(r,u)}catch(u){if(u instanceof I)return;ft(e,n,u,l)}finally{t.release(1)}})()}function ve(e){const{options:n,state:t}=e,{logOptions:i,timeController:o,GC_Interval:a}=n;if(!i.progress&&!a)return;bt(e);const r=o.now();if(mt(e,r))return dt(t,r)}function B(e){return e.options.abortSignalExternal?.aborted??!1}function Q(e){return e.abortSignal.aborted}async function W(e,n){const{pool:t,state:i,options:o}=e,{parallel:a,logOptions:r}=o;let l=null;for(;!B(e);){const u=t&&!Q(e);let f=!1;u&&(t.hold(1)||await H.poolWait({pool:t,count:1,hold:!0}),f=!0);try{if(n!=null?(l=n,n=null):e.state.debugMode||(l=e.variantsIterator.next()),l==null)break;const m=ve(e);if(E.isPromiseLike(m)&&await m,B(e))continue;if(u)yt(e,l),f=!1;else{r.debug&&t&&Q(e)&&r.func("debug",`[test-variants] parallel aborted, running sequential: tests=${i.tests}`);const h=ye(e,l);E.isPromiseLike(h)&&await h}}finally{f&&t.release(1)}}t&&(await H.poolWait({pool:t,count:a,hold:!0}),t.release(a))}function vt(e){const{pool:n,state:t,options:i}=e,{logOptions:o}=i;if(n)return W(e);let a=null;for(;!B(e)&&(e.state.debugMode||(a=e.variantsIterator.next()),a!=null);){const r=ve(e);if(E.isPromiseLike(r))return r.then(()=>W(e,a));if(B(e))continue;o.debug&&Q(e)&&o.func("debug",`[test-variants] parallel aborted, running sequential: tests=${t.tests}`);const l=ye(e,a);if(E.isPromiseLike(l))return l.then(()=>W(e))}}async function Et(e,n,t,i){const o=ct(i),{store:a,logOptions:r,abortSignalExternal:l,findBestError:u,dontThrowIfError:f,timeController:m,parallel:h}=o,y=new z.AbortControllerFast,p=new z.AbortControllerFast,b=E.combineAbortSignals(l,y.signal),x=E.combineAbortSignals(b,p.signal),O={abortSignal:b,timeController:m},g={abortSignal:x,timeController:m};a&&await a.replay({testRun:e,variantsIterator:n,testOptions:O,findBestErrorEnabled:!!u});const w=h<=1?null:new H.Pool(h);pt(r,t.startMemory);const V={options:o,testRun:e,variantsIterator:n,testOptions:O,testOptionsParallel:g,abortControllerGlobal:y,abortControllerParallel:p,abortSignal:x,pool:w,state:t};be(V);try{await vt(V),x.throwIfAborted()}catch(N){throw y.abort(new I),N}return b.throwIfAborted(),y.abort(new I),ht(V),await re(1),lt(t,n,f)}function xt(e){return function(t){return async function(o){const a=ge(o?.log),r=tt(e,{onError:o?.onError,log:a,pauseDebuggerOnError:o?.pauseDebuggerOnError}),l=o?.timeController??Y.timeControllerDefault,u=te(),f=Qe(l,u),m=o?.onModeChange;function h(p){f.pendingModeChange=p,m?.(p)}const y=at({argsTemplates:t,getSeed:o?.getSeed,iterationModes:o?.iterationModes,equals:o?.findBestError?.equals,limitArgOnError:o?.findBestError?.limitArgOnError,includeErrorVariant:o?.findBestError?.includeErrorVariant,timeController:l,onModeChange:h,limitCompletionCount:o?.cycles??1,limitTests:o?.limitTests,limitTime:o?.limitTime});return Et(r,y,f,o)}}}exports.createTestVariants=xt;
@@ -1,5 +1,5 @@
1
1
  import { timeControllerDefault as K } from "@flemist/time-controller";
2
- import { formatAny as me, deepCloneJsonLike as Je } from "@flemist/simple-utils";
2
+ import { formatAny as de, deepCloneJsonLike as Je } from "@flemist/simple-utils";
3
3
  import { isPromiseLike as M, 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";
@@ -21,7 +21,7 @@ function Q() {
21
21
  }
22
22
  const Qe = 1e3, q = [];
23
23
  function Ye(e) {
24
- return me(e, { pretty: !0, maxDepth: 5, maxItems: 50 });
24
+ return de(e, { pretty: !0, maxDepth: 5, maxItems: 50 });
25
25
  }
26
26
  function et(...e) {
27
27
  const n = e.map((t) => typeof t == "string" ? t : Ye(t)).join(" ");
@@ -32,25 +32,23 @@ function tt() {
32
32
  `);
33
33
  }
34
34
  globalThis.__getStressTestLogLast = tt;
35
- const de = (e, n) => {
35
+ const me = (e, n) => {
36
36
  et(n);
37
- }, ge = (e) => me(e, {
37
+ }, ge = (e) => de(e, {
38
38
  pretty: !0,
39
39
  maxDepth: 20,
40
40
  maxItems: 100,
41
41
  maxStringLength: 5e3,
42
- customToString: (n) => {
43
- if (typeof n == "function")
44
- return `function ${n.name || "anonymous"}()`;
45
- }
46
- }), S = {
42
+ dontExpandClassInstances: !0,
43
+ dontExpandFunctions: !0
44
+ }), x = {
47
45
  start: !0,
48
46
  progress: 5e3,
49
47
  completed: !0,
50
48
  error: !0,
51
49
  modeChange: !0,
52
50
  debug: !1,
53
- func: de,
51
+ func: me,
54
52
  format: ge
55
53
  }, rt = {
56
54
  start: !1,
@@ -59,19 +57,19 @@ const de = (e, n) => {
59
57
  error: !1,
60
58
  modeChange: !1,
61
59
  debug: !1,
62
- func: de,
60
+ func: me,
63
61
  format: ge
64
62
  };
65
63
  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
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
75
73
  };
76
74
  }
77
75
  function nt(e, n) {
@@ -91,7 +89,7 @@ function nt(e, n) {
91
89
  prevGcIterationsAsync: 0
92
90
  };
93
91
  }
94
- class T extends Ze {
92
+ class I extends Ze {
95
93
  }
96
94
  const ot = 50, it = 5;
97
95
  function ae(e, n) {
@@ -107,10 +105,10 @@ function st(e, n) {
107
105
  tests: ${c}
108
106
  ${t.format(l)}`
109
107
  ));
110
- const m = Date.now();
108
+ const d = Date.now();
111
109
  if (i)
112
110
  debugger;
113
- if (Date.now() - m > ot && a < it) {
111
+ if (Date.now() - d > ot && a < it) {
114
112
  t.func(
115
113
  "debug",
116
114
  `[test-variants] debug iteration: ${a}`
@@ -120,15 +118,15 @@ ${t.format(l)}`
120
118
  const y = o;
121
119
  throw o = null, n.onError && n.onError(y), y.error;
122
120
  }
123
- return function(u, c, m) {
121
+ return function(u, c, d) {
124
122
  try {
125
- const h = e(u, m);
123
+ const h = e(u, d);
126
124
  return M(h) ? h.then(
127
125
  (y) => ae(y, !0),
128
126
  (y) => r(y, u, c)
129
127
  ) : ae(h, !1);
130
128
  } catch (h) {
131
- return h instanceof T ? void 0 : r(h, u, c);
129
+ return h instanceof I ? void 0 : r(h, u, c);
132
130
  }
133
131
  };
134
132
  }
@@ -140,8 +138,8 @@ function U(e, n, t) {
140
138
  }
141
139
  function le(e, n, t, i) {
142
140
  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];
141
+ for (let d = 0; d < c; d++) {
142
+ const h = o[d];
145
143
  a[h] = void 0, r.push(-1), l.push(void 0), u.push(null);
146
144
  }
147
145
  return {
@@ -188,7 +186,7 @@ function w(e, n, t) {
188
186
  }
189
187
  return !t || a ? Math.min(o, i - 1) : i - 1;
190
188
  }
191
- function I(e) {
189
+ function T(e) {
192
190
  const n = e.indexes.length;
193
191
  for (let t = 0; t < n; t++) {
194
192
  const i = e.argLimits[t];
@@ -228,7 +226,7 @@ function he(e) {
228
226
  }
229
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);
230
228
  }
231
- if (I(e))
229
+ if (T(e))
232
230
  return C(e), !1;
233
231
  if (n && t)
234
232
  return !0;
@@ -239,26 +237,26 @@ function he(e) {
239
237
  const u = w(e, r, l), c = e.indexes[r] + 1;
240
238
  if (c <= u) {
241
239
  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;
240
+ for (let d = r + 1; d < i; d++)
241
+ e.args[e.argsNames[d]] = void 0;
244
242
  for (r++; r < i; r++) {
245
243
  e.argValues[r] = O(
246
244
  e,
247
245
  e.argsNames[r]
248
246
  );
249
- const m = w(e, r, l);
250
- if (m < 0)
247
+ const d = w(e, r, l);
248
+ if (d < 0)
251
249
  break;
252
- e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0], m > 0 && (l = !0);
250
+ e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0], d > 0 && (l = !0);
253
251
  }
254
252
  if (r >= i)
255
- return I(e) ? (C(e), !1) : !0;
253
+ return T(e) ? (C(e), !1) : !0;
256
254
  }
257
255
  }
258
256
  return C(e), !1;
259
257
  }
260
258
  function z(e) {
261
- I(e) && C(e);
259
+ T(e) && C(e);
262
260
  let n = !1, t = !0;
263
261
  const i = e.indexes.length;
264
262
  let o = i, a = !1, r = 0;
@@ -279,7 +277,7 @@ function z(e) {
279
277
  }
280
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);
281
279
  }
282
- if ((n || a) && t && !I(e))
280
+ if ((n || a) && t && !T(e))
283
281
  return !0;
284
282
  for (r--; r >= 0; r--) {
285
283
  if (e.argValues[r] == null)
@@ -289,17 +287,17 @@ function z(e) {
289
287
  let c = e.indexes[r] - 1;
290
288
  if (c > u && (c = u), c >= 0) {
291
289
  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;
290
+ for (let d = r + 1; d < i; d++)
291
+ e.args[e.argsNames[d]] = void 0;
294
292
  for (r++; r < i; r++) {
295
293
  e.argValues[r] = O(
296
294
  e,
297
295
  e.argsNames[r]
298
296
  );
299
- const m = w(e, r, l);
300
- if (m < 0)
297
+ const d = w(e, r, l);
298
+ if (d < 0)
301
299
  break;
302
- e.indexes[r] = m, e.args[e.argsNames[r]] = e.argValues[r][m], m > 0 && (l = !0);
300
+ e.indexes[r] = d, e.args[e.argsNames[r]] = e.argValues[r][d], d > 0 && (l = !0);
303
301
  }
304
302
  if (r >= i)
305
303
  return !0;
@@ -328,7 +326,7 @@ function at(e, n) {
328
326
  return null;
329
327
  e.indexes[a] = c, e.args[e.argsNames[a]] = e.argValues[a][c], e.indexes[a] < u && (o = !0);
330
328
  }
331
- return I(e) ? null : e.indexes.slice();
329
+ return T(e) ? null : e.indexes.slice();
332
330
  }
333
331
  function lt(e) {
334
332
  const n = e.indexes.length;
@@ -342,7 +340,7 @@ function lt(e) {
342
340
  return Math.random() < 0.5 ? he(e) : z(e);
343
341
  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);
344
342
  }
345
- return I(e) ? z(e) : !0;
343
+ return T(e) ? z(e) : !0;
346
344
  }
347
345
  function _(e) {
348
346
  return e.mode === "forward" || e.mode === "backward";
@@ -381,7 +379,7 @@ function ue(e, n) {
381
379
  return !0;
382
380
  }
383
381
  const ct = [{ mode: "forward" }];
384
- function mt(e) {
382
+ function dt(e) {
385
383
  const {
386
384
  argsTemplates: n,
387
385
  equals: t,
@@ -392,20 +390,20 @@ function mt(e) {
392
390
  onModeChange: l,
393
391
  limitCompletionCount: u,
394
392
  limitTests: c,
395
- limitTime: m
393
+ limitTime: d
396
394
  } = e, h = e.timeController ?? K, y = {
397
395
  templates: Je(n),
398
396
  extra: {}
399
397
  }, p = r == null || r.length === 0 ? ct : r, b = [];
400
- let E = null, L = null, g = 0, x = 0, V = !1, P = 0;
398
+ let E = null, L = null, g = 0, S = 0, V = !1, P = 0;
401
399
  function $() {
402
- V || (V = !0, P = h.now(), Se(), g = 0, te(), we());
400
+ V || (V = !0, P = h.now(), xe(), g = 0, te(), we());
403
401
  }
404
- function Se() {
402
+ function xe() {
405
403
  for (let s = 0, f = p.length; s < f; s++)
406
- b.push(xe());
404
+ b.push(Se());
407
405
  }
408
- function xe() {
406
+ function Se() {
409
407
  return {
410
408
  navigationState: le(
411
409
  y,
@@ -433,7 +431,7 @@ function mt(e) {
433
431
  l?.({
434
432
  mode: p[g],
435
433
  modeIndex: g,
436
- tests: x
434
+ tests: S
437
435
  });
438
436
  }
439
437
  function Me(s) {
@@ -442,25 +440,25 @@ function mt(e) {
442
440
  function re(s, f) {
443
441
  return $(), ue(y.templates, s) ? (E.limitArgOnError = f?.limitArg ?? i ?? null, E.includeErrorVariant = f?.includeLimit ?? o ?? !1, at(E, s)) : null;
444
442
  }
445
- function Te(s) {
443
+ function Ie(s) {
446
444
  const f = s?.args;
447
445
  if (f == null)
448
446
  return;
449
447
  $();
450
- const d = re(f);
451
- if (d != null) {
448
+ const m = re(f);
449
+ if (m != null) {
452
450
  L = {
453
451
  args: f,
454
452
  error: s?.error,
455
- tests: s?.tests ?? x
456
- }, E.argLimits = d;
453
+ tests: s?.tests ?? S
454
+ }, E.argLimits = m;
457
455
  for (let v = 0, D = b.length; v < D; v++) {
458
456
  const j = b[v].navigationState;
459
- j.argLimits = d;
457
+ j.argLimits = m;
460
458
  }
461
459
  }
462
460
  }
463
- function Ie() {
461
+ function Te() {
464
462
  return $(), Ve();
465
463
  }
466
464
  function Ve() {
@@ -470,7 +468,7 @@ function mt(e) {
470
468
  for (; ; ) {
471
469
  const s = qe();
472
470
  if (s != null)
473
- return b[g].testsInLastTurn++, x++, s;
471
+ return b[g].testsInLastTurn++, S++, s;
474
472
  if ($e()) {
475
473
  if (!Ge())
476
474
  return null;
@@ -484,10 +482,10 @@ function mt(e) {
484
482
  return !(Ce() || Oe() || G() && (Le() || !Ne()) || !Pe());
485
483
  }
486
484
  function Ce() {
487
- return c != null && x >= c;
485
+ return c != null && S >= c;
488
486
  }
489
487
  function Oe() {
490
- return m != null && h.now() - P >= m;
488
+ return d != null && h.now() - P >= d;
491
489
  }
492
490
  function Le() {
493
491
  if (!G())
@@ -529,23 +527,23 @@ function mt(e) {
529
527
  }
530
528
  function De() {
531
529
  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));
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));
535
533
  }
536
534
  if (!s)
537
535
  throw new Error("Unexpected behavior");
538
536
  return f;
539
537
  }
540
538
  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;
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;
543
541
  }
544
542
  function _e() {
545
543
  g = 0;
546
544
  for (let s = 0, f = b.length; s < f; s++) {
547
- const d = b[s];
548
- d.testsInLastTurn = 0, d.startTime = null;
545
+ const m = b[s];
546
+ m.testsInLastTurn = 0, m.startTime = null;
549
547
  }
550
548
  }
551
549
  function qe() {
@@ -578,10 +576,10 @@ function mt(e) {
578
576
  return _(s);
579
577
  }
580
578
  function Re(s) {
581
- const f = p[s], d = b[s];
579
+ const f = p[s], m = b[s];
582
580
  if (!A(f))
583
581
  throw new Error("Unexpected behavior");
584
- return d.cycleCount < (f.cycles ?? 1);
582
+ return m.cycleCount < (f.cycles ?? 1);
585
583
  }
586
584
  function Fe() {
587
585
  const s = p[g], f = b[g];
@@ -590,7 +588,7 @@ function mt(e) {
590
588
  return f.cycleCount++, f.cycleCount >= (s.cycles ?? 1) ? (f.cycleCount = 0, f.completedCount++, !0) : !1;
591
589
  }
592
590
  function je() {
593
- const s = p[g], f = b[g], d = f.navigationState;
591
+ const s = p[g], f = b[g], m = f.navigationState;
594
592
  if (N(s)) {
595
593
  if (F())
596
594
  return null;
@@ -598,24 +596,24 @@ function mt(e) {
598
596
  if (v != null)
599
597
  return f.startTime == null && (f.startTime = h.now()), v;
600
598
  }
601
- return He() ? (f.tryNextVariantAttempts = 0, N(s) && ze(), f.startTime == null && (f.startTime = h.now()), ne(d.args)) : (f.tryNextVariantAttempts++, null);
599
+ return He() ? (f.tryNextVariantAttempts = 0, N(s) && ze(), f.startTime == null && (f.startTime = h.now()), ne(m.args)) : (f.tryNextVariantAttempts++, null);
602
600
  }
603
601
  function We() {
604
- const s = p[g], d = b[g].navigationState;
602
+ const s = p[g], m = b[g].navigationState;
605
603
  if (!N(s))
606
604
  throw new Error("Unexpected behavior");
607
605
  if (F())
608
606
  throw new Error("Unexpected behavior");
609
607
  const v = s.attemptsPerVariant ?? 1;
610
- return d.attempts > 0 && d.attempts < v ? I(d) ? null : (d.attempts++, ne(d.args)) : null;
608
+ return m.attempts > 0 && m.attempts < v ? T(m) ? null : (m.attempts++, ne(m.args)) : null;
611
609
  }
612
610
  function ze() {
613
- const s = p[g], d = b[g].navigationState;
611
+ const s = p[g], m = b[g].navigationState;
614
612
  if (!N(s))
615
613
  throw new Error("Unexpected behavior");
616
614
  if (F())
617
615
  throw new Error("Unexpected behavior");
618
- d.attempts = 1;
616
+ m.attempts = 1;
619
617
  }
620
618
  function N(s) {
621
619
  return _(s);
@@ -627,21 +625,21 @@ function mt(e) {
627
625
  return (s.attemptsPerVariant ?? 1) <= 0;
628
626
  }
629
627
  function He() {
630
- const s = p[g], d = b[g].navigationState;
628
+ const s = p[g], m = b[g].navigationState;
631
629
  switch (s.mode) {
632
630
  case "forward":
633
- return he(d);
631
+ return he(m);
634
632
  case "backward":
635
- return z(d);
633
+ return z(m);
636
634
  case "random":
637
- return lt(d);
635
+ return lt(m);
638
636
  default:
639
637
  throw new Error(`Unknown mode: ${s.mode}`);
640
638
  }
641
639
  }
642
640
  function ne(s) {
643
641
  const f = { ...s };
644
- return a != null && (f.seed = a({ tests: x })), f;
642
+ return a != null && (f.seed = a({ tests: S })), f;
645
643
  }
646
644
  return {
647
645
  get limit() {
@@ -657,12 +655,12 @@ function mt(e) {
657
655
  return b;
658
656
  },
659
657
  get tests() {
660
- return x;
658
+ return S;
661
659
  },
662
660
  calcIndexes: re,
663
661
  extendTemplates: Me,
664
- addLimit: Te,
665
- next: Ie
662
+ addLimit: Ie,
663
+ next: Te
666
664
  };
667
665
  }
668
666
  function Y(e) {
@@ -672,7 +670,7 @@ function Y(e) {
672
670
  const n = Xe().then(() => e);
673
671
  return e <= 0 ? n : n.then(Y);
674
672
  }
675
- function dt(e, n, t) {
673
+ function mt(e, n, t) {
676
674
  const i = n.limit ? {
677
675
  error: n.limit.error,
678
676
  args: n.limit.args,
@@ -735,7 +733,7 @@ function ht(e, n, t, i) {
735
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(
736
734
  "debug",
737
735
  "[test-variants] sequentialOnError: aborting parallel, switching to sequential"
738
- ), o.abort(new T())) : l.debug && l.func(
736
+ ), o.abort(new I())) : l.debug && l.func(
739
737
  "debug",
740
738
  "[test-variants] parallel error in findBestError mode, continuing with new limits"
741
739
  );
@@ -801,7 +799,7 @@ function Et(e, n) {
801
799
  let t = "[test-variants] start";
802
800
  n != null && (t += `, memory: ${H(n)}`), e.func("start", t);
803
801
  }
804
- function St(e) {
802
+ function xt(e) {
805
803
  const { options: n, state: t } = e, { logOptions: i, timeController: o } = n;
806
804
  if (!i.completed)
807
805
  return;
@@ -820,7 +818,7 @@ function ye(e) {
820
818
  `[test-variants] ${vt(o.mode, o.modeIndex)}`
821
819
  ), t.pendingModeChange = null);
822
820
  }
823
- function xt(e) {
821
+ function St(e) {
824
822
  const { options: n, state: t } = e, { logOptions: i, timeController: o } = n, a = o.now();
825
823
  if (!i.progress || a - t.prevLogTime < i.progress)
826
824
  return !1;
@@ -837,7 +835,7 @@ function J(e, n) {
837
835
  e.debugMode = !1, n && (e.iterationsAsync += n.iterationsAsync, e.iterations += n.iterationsSync + n.iterationsAsync);
838
836
  }
839
837
  function X(e) {
840
- e.state.debugMode = !0, e.abortControllerParallel.abort(new T());
838
+ e.state.debugMode = !0, e.abortControllerParallel.abort(new I());
841
839
  }
842
840
  function ve(e, n) {
843
841
  const { testRun: t, testOptions: i, state: o } = e, a = o.tests;
@@ -861,7 +859,7 @@ function ve(e, n) {
861
859
  }
862
860
  J(o, r);
863
861
  } catch (r) {
864
- return r instanceof T ? void 0 : ce(e, n, r, a);
862
+ return r instanceof I ? void 0 : ce(e, n, r, a);
865
863
  }
866
864
  }
867
865
  function wt(e, n) {
@@ -880,7 +878,7 @@ function wt(e, n) {
880
878
  }
881
879
  J(r, u);
882
880
  } catch (u) {
883
- if (u instanceof T)
881
+ if (u instanceof I)
884
882
  return;
885
883
  ht(e, n, u, l);
886
884
  } finally {
@@ -892,7 +890,7 @@ function Ee(e) {
892
890
  const { options: n, state: t } = e, { logOptions: i, timeController: o, GC_Interval: a } = n;
893
891
  if (!i.progress && !a)
894
892
  return;
895
- xt(e);
893
+ St(e);
896
894
  const r = o.now();
897
895
  if (bt(e, r))
898
896
  return yt(t, r);
@@ -913,8 +911,8 @@ async function W(e, n) {
913
911
  try {
914
912
  if (n != null ? (l = n, n = null) : e.state.debugMode || (l = e.variantsIterator.next()), l == null)
915
913
  break;
916
- const m = Ee(e);
917
- if (M(m) && await m, k(e))
914
+ const d = Ee(e);
915
+ if (M(d) && await d, k(e))
918
916
  continue;
919
917
  if (u)
920
918
  wt(e, l), c = !1;
@@ -952,14 +950,14 @@ function Mt(e) {
952
950
  return l.then(() => W(e));
953
951
  }
954
952
  }
955
- async function Tt(e, n, t, i) {
953
+ async function It(e, n, t, i) {
956
954
  const o = pt(i), {
957
955
  store: a,
958
956
  logOptions: r,
959
957
  abortSignalExternal: l,
960
958
  findBestError: u,
961
959
  dontThrowIfError: c,
962
- timeController: m,
960
+ timeController: d,
963
961
  parallel: h
964
962
  } = o, y = new ie(), p = new ie(), b = oe(
965
963
  l,
@@ -969,10 +967,10 @@ async function Tt(e, n, t, i) {
969
967
  p.signal
970
968
  ), L = {
971
969
  abortSignal: b,
972
- timeController: m
970
+ timeController: d
973
971
  }, g = {
974
972
  abortSignal: E,
975
- timeController: m
973
+ timeController: d
976
974
  };
977
975
  a && await a.replay({
978
976
  testRun: e,
@@ -980,7 +978,7 @@ async function Tt(e, n, t, i) {
980
978
  testOptions: L,
981
979
  findBestErrorEnabled: !!u
982
980
  });
983
- const x = h <= 1 ? null : new Ke(h);
981
+ const S = h <= 1 ? null : new Ke(h);
984
982
  Et(r, t.startMemory);
985
983
  const V = {
986
984
  options: o,
@@ -991,16 +989,16 @@ async function Tt(e, n, t, i) {
991
989
  abortControllerGlobal: y,
992
990
  abortControllerParallel: p,
993
991
  abortSignal: E,
994
- pool: x,
992
+ pool: S,
995
993
  state: t
996
994
  };
997
995
  ye(V);
998
996
  try {
999
997
  await Mt(V), E.throwIfAborted();
1000
998
  } catch (P) {
1001
- throw y.abort(new T()), P;
999
+ throw y.abort(new I()), P;
1002
1000
  }
1003
- return b.throwIfAborted(), y.abort(new T()), St(V), await Y(1), dt(t, n, c);
1001
+ return b.throwIfAborted(), y.abort(new I()), xt(V), await Y(1), mt(t, n, c);
1004
1002
  }
1005
1003
  function Nt(e) {
1006
1004
  return function(t) {
@@ -1009,11 +1007,11 @@ function Nt(e) {
1009
1007
  onError: o?.onError,
1010
1008
  log: a,
1011
1009
  pauseDebuggerOnError: o?.pauseDebuggerOnError
1012
- }), l = o?.timeController ?? K, u = Q(), c = nt(l, u), m = o?.onModeChange;
1010
+ }), l = o?.timeController ?? K, u = Q(), c = nt(l, u), d = o?.onModeChange;
1013
1011
  function h(p) {
1014
- c.pendingModeChange = p, m?.(p);
1012
+ c.pendingModeChange = p, d?.(p);
1015
1013
  }
1016
- const y = mt({
1014
+ const y = dt({
1017
1015
  argsTemplates: t,
1018
1016
  getSeed: o?.getSeed,
1019
1017
  iterationModes: o?.iterationModes,
@@ -1026,7 +1024,7 @@ function Nt(e) {
1026
1024
  limitTests: o?.limitTests,
1027
1025
  limitTime: o?.limitTime
1028
1026
  });
1029
- return Tt(r, y, c, o);
1027
+ return It(r, y, c, o);
1030
1028
  };
1031
1029
  };
1032
1030
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("../createTestVariants-BdWikiOA.js"),F=require("path"),O=require("@flemist/async-utils"),y=require("@flemist/simple-utils"),x=require("@flemist/simple-utils/node"),P=require("fs");function v(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const m=v(F),u=v(P);async function b(e){const t=await u.promises.stat(e).catch(()=>null);if(t==null)return[];if(!t.isDirectory())throw new Error(`[saveErrorVariants] path is not a directory: ${e}`);return(await u.promises.readdir(e)).filter(n=>n.endsWith(".json")).sort((n,a)=>n>a?-1:n<a?1:0).map(n=>m.join(e,n))}async function A(e,t){const s=await u.promises.readFile(e,"utf-8");let r;try{r=JSON.parse(s)}catch{throw new Error(`[saveErrorVariants] invalid JSON in file: ${e}`)}if(t)try{return t(r)}catch{throw new Error(`[saveErrorVariants] jsonToArgs failed for file: ${e}`)}return r}function q(e){const t=Math.random().toString(36).substring(2);return y.formatDateFileName(e.sessionDate,"UTC")+"_"+t+".json"}async function D(e,t,s){let r;if(s){const n=s(e);typeof n=="string"?r=n:r=JSON.stringify(n,null,2)}else r=JSON.stringify(e,null,2);await u.promises.mkdir(m.dirname(t),{recursive:!0}),await u.promises.writeFile(t,r,"utf-8")}function L(e,t){const s=Math.max(e.length,t.length);for(let r=0;r<s;r++){const n=e[r],a=t[r];if(n==null){if(a==null)continue;return 1}if(a==null||n<a)return-1;if(n>a)return 1}return 0}class N{options;filePath;lastSavedArgs=null;constructor(t){this.options=t;const s=new Date;this.filePath=m.resolve(t.dir,t.getFilePath?.({sessionDate:s})??q({sessionDate:s}))}async save(t){y.deepEqualJsonLike(t,this.lastSavedArgs)||(this.lastSavedArgs={...t},await x.fileLock({filePath:this.filePath,func:()=>D(t,this.filePath,this.options.argsToJson)}))}async replay(t){const{testRun:s,variantsIterator:r,testOptions:n,findBestErrorEnabled:a}=t,h=this.options.useToFindBestError,E=this.options.limitArg??!1,V=this.options.extendTemplates??!1,S=this.options.attemptsPerVariant??1,g=new Map;function d(i){let o=g.get(i);return o===void 0&&(o=r.calcIndexes(i,{includeLimit:!1,limitArg:E}),g.set(i,o)),o}const w=await b(this.options.dir),f=[];for(let i=0,o=w.length;i<o;i++){const p=w[i],c=await A(p,this.options.jsonToArgs);V&&r.extendTemplates(c),d(c)!=null&&f.push(c)}function T(i,o){return L(d(i),d(o))}f.sort(T);for(let i=0,o=f.length;i<o;i++){const p=f[i];for(let c=0;c<S;c++)try{const l=s(p,0,n);O.isPromiseLike(l)&&await l}catch(l){if(h&&a){r.addLimit({args:p,error:l});break}throw l}}}}function k(e){return new N(e)}function _(e){const t=j.createTestVariants(e);return function(r){const n=t(r);return function(h){return n({...h,createSaveErrorVariantsStore:k})}}}exports.createTestVariants=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("../createTestVariants-6NbYYHA7.js"),F=require("path"),O=require("@flemist/async-utils"),y=require("@flemist/simple-utils"),x=require("@flemist/simple-utils/node"),P=require("fs");function v(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const m=v(F),u=v(P);async function b(e){const t=await u.promises.stat(e).catch(()=>null);if(t==null)return[];if(!t.isDirectory())throw new Error(`[saveErrorVariants] path is not a directory: ${e}`);return(await u.promises.readdir(e)).filter(n=>n.endsWith(".json")).sort((n,a)=>n>a?-1:n<a?1:0).map(n=>m.join(e,n))}async function A(e,t){const s=await u.promises.readFile(e,"utf-8");let r;try{r=JSON.parse(s)}catch{throw new Error(`[saveErrorVariants] invalid JSON in file: ${e}`)}if(t)try{return t(r)}catch{throw new Error(`[saveErrorVariants] jsonToArgs failed for file: ${e}`)}return r}function q(e){const t=Math.random().toString(36).substring(2);return y.formatDateFileName(e.sessionDate,"UTC")+"_"+t+".json"}async function D(e,t,s){let r;if(s){const n=s(e);typeof n=="string"?r=n:r=JSON.stringify(n,null,2)}else r=JSON.stringify(e,null,2);await u.promises.mkdir(m.dirname(t),{recursive:!0}),await u.promises.writeFile(t,r,"utf-8")}function L(e,t){const s=Math.max(e.length,t.length);for(let r=0;r<s;r++){const n=e[r],a=t[r];if(n==null){if(a==null)continue;return 1}if(a==null||n<a)return-1;if(n>a)return 1}return 0}class N{options;filePath;lastSavedArgs=null;constructor(t){this.options=t;const s=new Date;this.filePath=m.resolve(t.dir,t.getFilePath?.({sessionDate:s})??q({sessionDate:s}))}async save(t){y.deepEqualJsonLike(t,this.lastSavedArgs)||(this.lastSavedArgs={...t},await x.fileLock({filePath:this.filePath,func:()=>D(t,this.filePath,this.options.argsToJson)}))}async replay(t){const{testRun:s,variantsIterator:r,testOptions:n,findBestErrorEnabled:a}=t,h=this.options.useToFindBestError,E=this.options.limitArg??!1,V=this.options.extendTemplates??!1,S=this.options.attemptsPerVariant??1,g=new Map;function d(i){let o=g.get(i);return o===void 0&&(o=r.calcIndexes(i,{includeLimit:!1,limitArg:E}),g.set(i,o)),o}const w=await b(this.options.dir),f=[];for(let i=0,o=w.length;i<o;i++){const p=w[i],c=await A(p,this.options.jsonToArgs);V&&r.extendTemplates(c),d(c)!=null&&f.push(c)}function T(i,o){return L(d(i),d(o))}f.sort(T);for(let i=0,o=f.length;i<o;i++){const p=f[i];for(let c=0;c<S;c++)try{const l=s(p,0,n);O.isPromiseLike(l)&&await l}catch(l){if(h&&a){r.addLimit({args:p,error:l});break}throw l}}}}function k(e){return new N(e)}function _(e){const t=j.createTestVariants(e);return function(r){const n=t(r);return function(h){return n({...h,createSaveErrorVariantsStore:k})}}}exports.createTestVariants=_;
@@ -1,4 +1,4 @@
1
- import { c as x } from "../createTestVariants-BiFu-zG6.mjs";
1
+ import { c as x } from "../createTestVariants-DHWt92RI.mjs";
2
2
  import * as d from "path";
3
3
  import { isPromiseLike as F } from "@flemist/async-utils";
4
4
  import { formatDateFileName as S, deepEqualJsonLike as A } from "@flemist/simple-utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/test-variants",
3
- "version": "5.0.9",
3
+ "version": "5.0.11",
4
4
  "description": "Runs a test function with all possible combinations of its parameters.",
5
5
  "sideEffects": false,
6
6
  "types": "build/common/index.d.ts",
@@ -144,7 +144,7 @@
144
144
  "dependencies": {
145
145
  "@flemist/abort-controller-fast": "^1.0.0",
146
146
  "@flemist/async-utils": "^1.2.8",
147
- "@flemist/simple-utils": "^2.1.14",
147
+ "@flemist/simple-utils": "^2.1.15",
148
148
  "@flemist/time-controller": "^1.0.4",
149
149
  "@flemist/time-limits": "^2.0.4",
150
150
  "tslib": ">=2.8.1"