@flemist/test-variants 0.0.2 → 0.0.3

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,24 +1,26 @@
1
- !function(r){"use strict";function n(r,n){
2
- return function(t){
3
- var e=Object.keys(t),o=Object.values(t),c=e.length,u={}
4
- ;function f(r){var n=o[r]
5
- ;return"function"==typeof n&&(n=n(u)),n}
6
- for(var i=[],a=[],s=0;s<c;s++)i[s]=-1,a[s]=[]
7
- ;function l(){for(var r=c-1;r>=0;r--){var n=i[r]+1
8
- ;if(n<a[r].length){
9
- for(i[r]=n,u[e[r]]=a[r][n],r++;r<c;r++){var t=f(r)
10
- ;if(0===t.length)break;i[r]=0,a[r]=t,u[e[r]]=t[0]}
11
- if(r>=c)return!0}}return!1}a[0]=f(0)
12
- ;var v=0,h=!1,y=0;function b(r){
13
- console.error(JSON.stringify(u,null,2)),console.error(r)
14
- ;var n=Date.now()
15
- ;throw Date.now()-n>5&&y<5&&(h=!0,g(),y++),r}
16
- function g(){for(;h||l();)try{v++;var t=r(u)
17
- ;if(t&&"function"==typeof t.then)return n&&b(new Error("Unexpected Promise result for sync test function")),
18
- t.then(g).catch(b)}catch(r){b(r)}return v}
19
- return g()}}r.createTestVariants=function(r){
20
- return n(r,!1)
1
+ !function(r){"use strict";function t(r,t){
2
+ return function(e){
3
+ var n=Object.keys(e),o=Object.values(e),u=n.length,c={}
4
+ ;function f(r){var t=o[r]
5
+ ;return"function"==typeof t&&(t=t(c)),t}
6
+ for(var i=[],a=[],s=0;s<u;s++)i[s]=-1,a[s]=[]
7
+ ;function l(){for(var r=u-1;r>=0;r--){var t=i[r]+1
8
+ ;if(t<a[r].length){
9
+ for(i[r]=t,c[n[r]]=a[r][t],r++;r<u;r++){var e=f(r)
10
+ ;if(0===e.length)break;i[r]=0,a[r]=e,c[n[r]]=e[0]}
11
+ if(r>=u)return!0}}return!1}a[0]=f(0)
12
+ ;var v=0,y=!1,h=0;function b(r){
13
+ console.error(JSON.stringify(c,null,2)),console.error(r)
14
+ ;var t=Date.now()
15
+ ;throw Date.now()-t>50&&h<5&&(y=!0,p(0),h++),r}
16
+ function p(e){
17
+ for(v+="number"==typeof e?e:1;y||l();)try{
18
+ var n=r(c)
19
+ ;if("object"==typeof n&&n&&"function"==typeof n.then)return t&&b(new Error("Unexpected Promise result for sync test function")),
20
+ n.then(p).catch(b);v+="number"==typeof n?n:1
21
+ }catch(r){b(r)}return v}return p(0)}}
22
+ r.createTestVariants=function(r){return t(r,!1)
21
23
  },r.createTestVariantsSync=function(r){
22
- return n(r,!0)
24
+ return t(r,!0)
23
25
  },Object.defineProperty(r,"__esModule",{value:!0})
24
26
  }({});
@@ -43,7 +43,7 @@ function _createTestVariants(test, sync) {
43
43
  }
44
44
  return false;
45
45
  }
46
- let iteration = 0;
46
+ let iterations = 0;
47
47
  let debug = false;
48
48
  let debugIteration = 0;
49
49
  function onError(err) {
@@ -53,32 +53,35 @@ function _createTestVariants(test, sync) {
53
53
  const time0 = Date.now();
54
54
  // eslint-disable-next-line no-debugger
55
55
  debugger;
56
- if (Date.now() - time0 > 5 && debugIteration < 5) {
56
+ if (Date.now() - time0 > 50 && debugIteration < 5) {
57
57
  debug = true;
58
- next();
58
+ next(0);
59
59
  debugIteration++;
60
60
  }
61
61
  throw err;
62
62
  }
63
- function next() {
63
+ function next(value) {
64
+ iterations += typeof value === 'number' ? value : 1;
64
65
  while (debug || nextVariant()) {
65
66
  try {
66
- iteration++;
67
67
  const promise = test(variantArgs);
68
- if (promise && typeof promise.then === 'function') {
68
+ if (typeof promise === 'object' && promise && typeof promise.then === 'function') {
69
69
  if (sync) {
70
70
  onError(new Error('Unexpected Promise result for sync test function'));
71
71
  }
72
72
  return promise.then(next).catch(onError);
73
73
  }
74
+ else {
75
+ iterations += typeof promise === 'number' ? promise : 1;
76
+ }
74
77
  }
75
78
  catch (err) {
76
79
  onError(err);
77
80
  }
78
81
  }
79
- return iteration;
82
+ return iterations;
80
83
  }
81
- return next();
84
+ return next(0);
82
85
  };
83
86
  }
84
87
  function createTestVariantsSync(test) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/test-variants",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Runs a test function with all possible combinations of its parameters.",
5
5
  "main": "dist/node/index.cjs",
6
6
  "types": "dist/node/index.d.ts",