tape-six 1.7.13 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +3 -1
  2. package/TESTING.md +246 -47
  3. package/bin/tape6-server.js +19 -19
  4. package/index.d.ts +67 -0
  5. package/llms-full.txt +102 -0
  6. package/llms.txt +66 -0
  7. package/package.json +13 -4
  8. package/skills/write-tests/SKILL.md +63 -16
  9. package/src/State.js +26 -21
  10. package/src/Tester.js +59 -27
  11. package/src/deep6/env.d.ts +174 -0
  12. package/src/deep6/env.js +4 -4
  13. package/src/deep6/index.d.ts +86 -0
  14. package/src/deep6/index.js +10 -7
  15. package/src/deep6/traverse/assemble.d.ts +59 -0
  16. package/src/deep6/traverse/assemble.js +4 -3
  17. package/src/deep6/traverse/clone.d.ts +57 -0
  18. package/src/deep6/traverse/clone.js +4 -2
  19. package/src/deep6/traverse/deref.d.ts +59 -0
  20. package/src/deep6/traverse/deref.js +3 -2
  21. package/src/deep6/traverse/preprocess.d.ts +65 -0
  22. package/src/deep6/traverse/preprocess.js +2 -1
  23. package/src/deep6/traverse/walk.d.ts +219 -0
  24. package/src/deep6/traverse/walk.js +9 -4
  25. package/src/deep6/unifiers/matchCondition.d.ts +45 -0
  26. package/src/deep6/unifiers/matchCondition.js +1 -0
  27. package/src/deep6/unifiers/matchInstanceOf.d.ts +37 -0
  28. package/src/deep6/unifiers/matchInstanceOf.js +1 -0
  29. package/src/deep6/unifiers/matchString.d.ts +56 -0
  30. package/src/deep6/unifiers/matchString.js +1 -0
  31. package/src/deep6/unifiers/matchTypeOf.d.ts +37 -0
  32. package/src/deep6/unifiers/matchTypeOf.js +1 -0
  33. package/src/deep6/unifiers/ref.d.ts +52 -0
  34. package/src/deep6/unifiers/ref.js +1 -0
  35. package/src/deep6/unify.d.ts +95 -0
  36. package/src/deep6/unify.js +130 -66
  37. package/src/deep6/utils/replaceVars.d.ts +25 -0
  38. package/src/deep6/utils/replaceVars.js +23 -19
  39. package/src/response.d.ts +43 -0
  40. package/src/response.js +57 -0
  41. package/src/server.d.ts +81 -0
  42. package/src/server.js +69 -0
  43. package/src/test.js +26 -53
package/src/test.js CHANGED
@@ -258,40 +258,45 @@ test.todo = function todo(name, options, testFn) {
258
258
  return test({...options, todo: true});
259
259
  };
260
260
 
261
- test.asPromise = function asPromise(name, options, testFn) {
262
- const currentTester = getTester();
263
- if (currentTester) {
264
- return currentTester.asPromise(name, options, testFn);
265
- }
266
- options = processArgs(name, options, testFn);
261
+ const wrapAsPromiseFn = options => {
267
262
  if (options.testFn) {
268
- const testFn = options.testFn;
263
+ const fn = options.testFn;
269
264
  options.testFn = tester =>
270
265
  new Promise((resolve, reject) => {
271
266
  try {
272
- testFn(tester, resolve, reject);
267
+ fn(tester, resolve, reject);
273
268
  } catch (error) {
274
269
  reject(error);
275
270
  }
276
271
  });
277
272
  }
278
- return test(options);
273
+ return options;
274
+ };
275
+
276
+ test.asPromise = function asPromise(name, options, testFn) {
277
+ const currentTester = getTester();
278
+ if (currentTester) {
279
+ return currentTester.asPromise(name, options, testFn);
280
+ }
281
+ return test(wrapAsPromiseFn(processArgs(name, options, testFn)));
279
282
  };
280
283
 
281
284
  // test() (an embedded test runner) is added here to ./Tester.js to avoid circular dependencies
282
285
 
286
+ const queueEmbedded = async function (tester, options) {
287
+ if (tester.lastEmbeddedTest) {
288
+ const last = tester.lastEmbeddedTest,
289
+ deferred = makeDeferred();
290
+ tester.lastEmbeddedTest = deferred.promise;
291
+ await last;
292
+ return runTests([{options}]).then(deferred.resolve, deferred.reject);
293
+ }
294
+ return (tester.lastEmbeddedTest = runTests([{options}]));
295
+ };
296
+
283
297
  Tester.prototype.test = async function test(name, options, testFn) {
284
298
  options = processArgs(name, options, testFn);
285
- if (!this.state?.skip) {
286
- if (this.lastEmbeddedTest) {
287
- const last = this.lastEmbeddedTest,
288
- deferred = makeDeferred();
289
- this.lastEmbeddedTest = deferred.promise;
290
- await last;
291
- return runTests([{options}]).then(deferred.resolve, deferred.reject);
292
- }
293
- return (this.lastEmbeddedTest = runTests([{options}]));
294
- }
299
+ if (!this.state?.skip) return queueEmbedded(this, options);
295
300
  this.comment('SKIP test: ' + options.name);
296
301
  };
297
302
 
@@ -302,45 +307,13 @@ Tester.prototype.skip = async function skip(name, options, testFn) {
302
307
 
303
308
  Tester.prototype.todo = async function todo(name, options, testFn) {
304
309
  options = processArgs(name, options, testFn);
305
- if (!this.state?.skip) {
306
- if (this.lastEmbeddedTest) {
307
- const last = this.lastEmbeddedTest,
308
- deferred = makeDeferred();
309
- this.lastEmbeddedTest = deferred.promise;
310
- await last;
311
- return runTests([{options: {...options, todo: true}}]).then(
312
- deferred.resolve,
313
- deferred.reject
314
- );
315
- }
316
- return (this.lastEmbeddedTest = runTests([{options: {...options, todo: true}}]));
317
- }
310
+ if (!this.state?.skip) return queueEmbedded(this, {...options, todo: true});
318
311
  this.comment('SKIP test: ' + options.name);
319
312
  };
320
313
 
321
314
  Tester.prototype.asPromise = async function asPromise(name, options, testFn) {
322
315
  options = processArgs(name, options, testFn);
323
- if (!this.state?.skip) {
324
- if (options.testFn) {
325
- const testFn = options.testFn;
326
- options.testFn = tester =>
327
- new Promise((resolve, reject) => {
328
- try {
329
- testFn(tester, resolve, reject);
330
- } catch (error) {
331
- reject(error);
332
- }
333
- });
334
- }
335
- if (this.lastEmbeddedTest) {
336
- const last = this.lastEmbeddedTest,
337
- deferred = makeDeferred();
338
- this.lastEmbeddedTest = deferred.promise;
339
- await last;
340
- return runTests([{options}]).then(deferred.resolve, deferred.reject);
341
- }
342
- return (this.lastEmbeddedTest = runTests([{options}]));
343
- }
316
+ if (!this.state?.skip) return queueEmbedded(this, wrapAsPromiseFn(options));
344
317
  this.comment('SKIP test: ' + options.name);
345
318
  };
346
319