qunitx 1.2.17 → 1.2.19

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.
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
10
14
  };
11
15
  var __copyProps = (to, from, except, desc) => {
12
16
  if (from && typeof from === "object" || typeof from === "function") {
@@ -150,7 +154,7 @@ var require_qunit = __commonJS({
150
154
  var g = getGlobalThis();
151
155
  var console$1 = g.console;
152
156
  var setTimeout$1 = g.setTimeout;
153
- var clearTimeout2 = g.clearTimeout;
157
+ var clearTimeout = g.clearTimeout;
154
158
  var process$1 = g.process;
155
159
  var window$1 = g.window;
156
160
  var document = window$1 && window$1.document;
@@ -168,22 +172,22 @@ var require_qunit = __commonJS({
168
172
  var StringMap = typeof g.Map === "function" && typeof g.Map.prototype.keys === "function" && typeof g.Symbol === "function" && _typeof(g.Symbol.iterator) === "symbol" ? g.Map : function StringMap2(input) {
169
173
  var _this = this;
170
174
  var store = /* @__PURE__ */ Object.create(null);
171
- var hasOwn3 = Object.prototype.hasOwnProperty;
175
+ var hasOwn2 = Object.prototype.hasOwnProperty;
172
176
  this.has = function(strKey) {
173
- return hasOwn3.call(store, strKey);
177
+ return hasOwn2.call(store, strKey);
174
178
  };
175
179
  this.get = function(strKey) {
176
180
  return store[strKey];
177
181
  };
178
182
  this.set = function(strKey, val) {
179
- if (!hasOwn3.call(store, strKey)) {
183
+ if (!hasOwn2.call(store, strKey)) {
180
184
  this.size++;
181
185
  }
182
186
  store[strKey] = val;
183
187
  return this;
184
188
  };
185
189
  this.delete = function(strKey) {
186
- if (hasOwn3.call(store, strKey)) {
190
+ if (hasOwn2.call(store, strKey)) {
187
191
  delete store[strKey];
188
192
  this.size--;
189
193
  }
@@ -242,25 +246,25 @@ var require_qunit = __commonJS({
242
246
  } : function(elem, array) {
243
247
  return array.indexOf(elem) !== -1;
244
248
  };
245
- function objectValues2(obj) {
249
+ function objectValues(obj) {
246
250
  var allowArray = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
247
251
  var vals = allowArray && is("array", obj) ? [] : {};
248
252
  for (var key in obj) {
249
253
  if (hasOwn$1.call(obj, key)) {
250
254
  var val = obj[key];
251
- vals[key] = val === Object(val) ? objectValues2(val, allowArray) : val;
255
+ vals[key] = val === Object(val) ? objectValues(val, allowArray) : val;
252
256
  }
253
257
  }
254
258
  return vals;
255
259
  }
256
- function objectValuesSubset2(obj, model) {
260
+ function objectValuesSubset(obj, model) {
257
261
  if (obj !== Object(obj)) {
258
262
  return obj;
259
263
  }
260
264
  var subset = {};
261
265
  for (var key in model) {
262
266
  if (hasOwn$1.call(model, key) && hasOwn$1.call(obj, key)) {
263
- subset[key] = objectValuesSubset2(obj[key], model[key]);
267
+ subset[key] = objectValuesSubset(obj[key], model[key]);
264
268
  }
265
269
  }
266
270
  return subset;
@@ -277,7 +281,7 @@ var require_qunit = __commonJS({
277
281
  }
278
282
  return a;
279
283
  }
280
- function objectType2(obj) {
284
+ function objectType(obj) {
281
285
  if (typeof obj === "undefined") {
282
286
  return "undefined";
283
287
  }
@@ -307,7 +311,7 @@ var require_qunit = __commonJS({
307
311
  }
308
312
  }
309
313
  function is(type, obj) {
310
- return objectType2(obj) === type;
314
+ return objectType(obj) === type;
311
315
  }
312
316
  function generateHash(module3, testName) {
313
317
  var str = module3 + "" + testName;
@@ -322,7 +326,7 @@ var require_qunit = __commonJS({
322
326
  }
323
327
  return hex.slice(-8);
324
328
  }
325
- function errorString2(error) {
329
+ function errorString(error) {
326
330
  var resultErrorString = String(error);
327
331
  if (resultErrorString.slice(0, 7) === "[object") {
328
332
  return (error.name || "Error") + (error.message ? ": ".concat(error.message) : "");
@@ -485,8 +489,8 @@ var require_qunit = __commonJS({
485
489
  a,
486
490
  b
487
491
  });
488
- var aObjType = objectType2(a);
489
- var bObjType = objectType2(b);
492
+ var aObjType = objectType(a);
493
+ var bObjType = objectType(b);
490
494
  if (aObjType !== "object" || bObjType !== "object") {
491
495
  return aObjType === bObjType && objTypeCallbacks[aObjType](a, b);
492
496
  }
@@ -517,7 +521,7 @@ var require_qunit = __commonJS({
517
521
  var aType = _typeof(a);
518
522
  var bType = _typeof(b);
519
523
  if (aType !== bType) {
520
- return (aType === "object" && BOXABLE_TYPES.has(objectType2(a)) ? a.valueOf() : a) === (bType === "object" && BOXABLE_TYPES.has(objectType2(b)) ? b.valueOf() : b);
524
+ return (aType === "object" && BOXABLE_TYPES.has(objectType(a)) ? a.valueOf() : a) === (bType === "object" && BOXABLE_TYPES.has(objectType(b)) ? b.valueOf() : b);
521
525
  }
522
526
  return entryTypeCallbacks[aType](a, b);
523
527
  }
@@ -555,6 +559,7 @@ var require_qunit = __commonJS({
555
559
  failOnZeroTests: true,
556
560
  // Select by pattern or case-insensitive substring match against "moduleName: testName"
557
561
  filter: void 0,
562
+ ignoreUnhandledRejections: false,
558
563
  testFilter: null,
559
564
  // TODO: Make explicit in QUnit 3.
560
565
  // fixture: undefined,
@@ -1317,7 +1322,7 @@ var require_qunit = __commonJS({
1317
1322
  }
1318
1323
  this.test.timeout = duration;
1319
1324
  if (config.timeout) {
1320
- clearTimeout2(config.timeout);
1325
+ clearTimeout(config.timeout);
1321
1326
  config.timeout = null;
1322
1327
  if (config.timeoutHandler && this.test.timeout > 0) {
1323
1328
  this.test.internalResetTimeout(this.test.timeout);
@@ -1484,8 +1489,8 @@ var require_qunit = __commonJS({
1484
1489
  }, {
1485
1490
  key: "propEqual",
1486
1491
  value: function propEqual(actual, expected, message) {
1487
- actual = objectValues2(actual);
1488
- expected = objectValues2(expected);
1492
+ actual = objectValues(actual);
1493
+ expected = objectValues(expected);
1489
1494
  this.pushResult({
1490
1495
  result: equiv(actual, expected),
1491
1496
  actual,
@@ -1496,8 +1501,8 @@ var require_qunit = __commonJS({
1496
1501
  }, {
1497
1502
  key: "notPropEqual",
1498
1503
  value: function notPropEqual(actual, expected, message) {
1499
- actual = objectValues2(actual);
1500
- expected = objectValues2(expected);
1504
+ actual = objectValues(actual);
1505
+ expected = objectValues(expected);
1501
1506
  this.pushResult({
1502
1507
  result: !equiv(actual, expected),
1503
1508
  actual,
@@ -1509,8 +1514,8 @@ var require_qunit = __commonJS({
1509
1514
  }, {
1510
1515
  key: "propContains",
1511
1516
  value: function propContains(actual, expected, message) {
1512
- actual = objectValuesSubset2(actual, expected);
1513
- expected = objectValues2(expected, false);
1517
+ actual = objectValuesSubset(actual, expected);
1518
+ expected = objectValues(expected, false);
1514
1519
  this.pushResult({
1515
1520
  result: equiv(actual, expected),
1516
1521
  actual,
@@ -1521,8 +1526,8 @@ var require_qunit = __commonJS({
1521
1526
  }, {
1522
1527
  key: "notPropContains",
1523
1528
  value: function notPropContains(actual, expected, message) {
1524
- actual = objectValuesSubset2(actual, expected);
1525
- expected = objectValues2(expected);
1529
+ actual = objectValuesSubset(actual, expected);
1530
+ expected = objectValues(expected);
1526
1531
  this.pushResult({
1527
1532
  result: !equiv(actual, expected),
1528
1533
  actual,
@@ -1576,7 +1581,7 @@ var require_qunit = __commonJS({
1576
1581
  }, {
1577
1582
  key: "throws",
1578
1583
  value: function throws(block, expected, message) {
1579
- var _validateExpectedExce = validateExpectedExceptionArgs2(expected, message, "throws");
1584
+ var _validateExpectedExce = validateExpectedExceptionArgs(expected, message, "throws");
1580
1585
  var _validateExpectedExce2 = _slicedToArray(_validateExpectedExce, 2);
1581
1586
  expected = _validateExpectedExce2[0];
1582
1587
  message = _validateExpectedExce2[1];
@@ -1599,7 +1604,7 @@ var require_qunit = __commonJS({
1599
1604
  }
1600
1605
  currentTest.ignoreGlobalErrors = false;
1601
1606
  if (actual) {
1602
- var _validateException = validateException2(actual, expected, message);
1607
+ var _validateException = validateException(actual, expected, message);
1603
1608
  var _validateException2 = _slicedToArray(_validateException, 3);
1604
1609
  result = _validateException2[0];
1605
1610
  expected = _validateException2[1];
@@ -1608,15 +1613,16 @@ var require_qunit = __commonJS({
1608
1613
  currentTest.assert.pushResult({
1609
1614
  result,
1610
1615
  // undefined if it didn't throw
1611
- actual: actual && errorString2(actual),
1616
+ actual: actual && errorString(actual),
1612
1617
  expected,
1613
1618
  message
1614
1619
  });
1620
+ return actual;
1615
1621
  }
1616
1622
  }, {
1617
1623
  key: "rejects",
1618
1624
  value: function rejects(promise, expected, message) {
1619
- var _validateExpectedExce3 = validateExpectedExceptionArgs2(expected, message, "rejects");
1625
+ var _validateExpectedExce3 = validateExpectedExceptionArgs(expected, message, "rejects");
1620
1626
  var _validateExpectedExce4 = _slicedToArray(_validateExpectedExce3, 2);
1621
1627
  expected = _validateExpectedExce4[0];
1622
1628
  message = _validateExpectedExce4[1];
@@ -1640,7 +1646,7 @@ var require_qunit = __commonJS({
1640
1646
  done();
1641
1647
  }, function handleRejection(actual) {
1642
1648
  var result;
1643
- var _validateException3 = validateException2(actual, expected, message);
1649
+ var _validateException3 = validateException(actual, expected, message);
1644
1650
  var _validateException4 = _slicedToArray(_validateException3, 3);
1645
1651
  result = _validateException4[0];
1646
1652
  expected = _validateException4[1];
@@ -1648,17 +1654,18 @@ var require_qunit = __commonJS({
1648
1654
  currentTest.assert.pushResult({
1649
1655
  result,
1650
1656
  // leave rejection value of undefined as-is
1651
- actual: actual && errorString2(actual),
1657
+ actual: actual && errorString(actual),
1652
1658
  expected,
1653
1659
  message
1654
1660
  });
1655
1661
  done();
1662
+ return actual;
1656
1663
  });
1657
1664
  }
1658
1665
  }]);
1659
1666
  })();
1660
- function validateExpectedExceptionArgs2(expected, message, assertionMethod) {
1661
- var expectedType = objectType2(expected);
1667
+ function validateExpectedExceptionArgs(expected, message, assertionMethod) {
1668
+ var expectedType = objectType(expected);
1662
1669
  if (expectedType === "string") {
1663
1670
  if (message === void 0) {
1664
1671
  message = expected;
@@ -1675,25 +1682,25 @@ var require_qunit = __commonJS({
1675
1682
  }
1676
1683
  return [expected, message];
1677
1684
  }
1678
- function validateException2(actual, expected, message) {
1685
+ function validateException(actual, expected, message) {
1679
1686
  var result = false;
1680
- var expectedType = objectType2(expected);
1687
+ var expectedType = objectType(expected);
1681
1688
  if (!expected) {
1682
1689
  result = true;
1683
1690
  } else if (expectedType === "regexp") {
1684
- result = expected.test(errorString2(actual));
1691
+ result = expected.test(errorString(actual));
1685
1692
  expected = String(expected);
1686
1693
  } else if (expectedType === "function" && expected.prototype !== void 0 && actual instanceof expected) {
1687
1694
  result = true;
1688
1695
  } else if (expectedType === "object") {
1689
1696
  result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;
1690
- expected = errorString2(expected);
1697
+ expected = errorString(expected);
1691
1698
  } else if (expectedType === "function") {
1692
1699
  try {
1693
1700
  result = expected.call({}, actual) === true;
1694
1701
  expected = null;
1695
1702
  } catch (e) {
1696
- expected = errorString2(e);
1703
+ expected = errorString(e);
1697
1704
  }
1698
1705
  }
1699
1706
  return [result, expected, message];
@@ -2275,7 +2282,7 @@ var require_qunit = __commonJS({
2275
2282
  try {
2276
2283
  promise = hook.call(_this2.testEnvironment, _this2.assert);
2277
2284
  } catch (error) {
2278
- _this2.pushFailure("Global " + hookName + " failed on " + _this2.testName + ": " + errorString2(error), extractStacktrace(error, 0));
2285
+ _this2.pushFailure("Global " + hookName + " failed on " + _this2.testName + ": " + errorString(error), extractStacktrace(error, 0));
2279
2286
  return;
2280
2287
  }
2281
2288
  }
@@ -2341,7 +2348,7 @@ var require_qunit = __commonJS({
2341
2348
  finish: function finish() {
2342
2349
  config.current = this;
2343
2350
  if (setTimeout$1) {
2344
- clearTimeout2(this.timeout);
2351
+ clearTimeout(this.timeout);
2345
2352
  config.timeoutHandler = null;
2346
2353
  }
2347
2354
  this.callback = void 0;
@@ -2554,7 +2561,7 @@ var require_qunit = __commonJS({
2554
2561
  * @param {number} timeoutDuration
2555
2562
  */
2556
2563
  internalResetTimeout: function internalResetTimeout(timeoutDuration) {
2557
- clearTimeout2(config.timeout);
2564
+ clearTimeout(config.timeout);
2558
2565
  config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
2559
2566
  },
2560
2567
  /**
@@ -2662,10 +2669,10 @@ var require_qunit = __commonJS({
2662
2669
  internalRecover(test4);
2663
2670
  };
2664
2671
  };
2665
- clearTimeout2(config.timeout);
2672
+ clearTimeout(config.timeout);
2666
2673
  config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
2667
2674
  } else {
2668
- clearTimeout2(config.timeout);
2675
+ clearTimeout(config.timeout);
2669
2676
  config.timeout = setTimeout$1(function() {
2670
2677
  config.timeout = null;
2671
2678
  if (!config._deprecated_timeout_shown) {
@@ -2960,12 +2967,12 @@ var require_qunit = __commonJS({
2960
2967
  return;
2961
2968
  }
2962
2969
  if (setTimeout$1) {
2963
- clearTimeout2(config.timeout);
2970
+ clearTimeout(config.timeout);
2964
2971
  config.timeout = setTimeout$1(function() {
2965
2972
  if (test4.pauses.size > 0) {
2966
2973
  return;
2967
2974
  }
2968
- clearTimeout2(config.timeout);
2975
+ clearTimeout(config.timeout);
2969
2976
  config.timeout = null;
2970
2977
  config.blocking = false;
2971
2978
  config.pq.advance();
@@ -3355,7 +3362,7 @@ var require_qunit = __commonJS({
3355
3362
  this.log("not ok ".concat(this.testCount, " ").concat($.red("global failure")));
3356
3363
  this.logError(error);
3357
3364
  }
3358
- this.log("Bail out! " + errorString2(error).split("\n")[0]);
3365
+ this.log("Bail out! " + errorString(error).split("\n")[0]);
3359
3366
  if (this.ended) {
3360
3367
  this.logError(error);
3361
3368
  }
@@ -3415,7 +3422,7 @@ var require_qunit = __commonJS({
3415
3422
  key: "logError",
3416
3423
  value: function logError(error) {
3417
3424
  var out = " ---";
3418
- out += "\n message: ".concat(prettyYamlValue(errorString2(error)));
3425
+ out += "\n message: ".concat(prettyYamlValue(errorString(error)));
3419
3426
  out += "\n severity: ".concat(prettyYamlValue("failed"));
3420
3427
  if (error && error.stack) {
3421
3428
  var fmtStack = annotateStacktrace(error.stack, $.grey, error.toString());
@@ -3634,7 +3641,7 @@ var require_qunit = __commonJS({
3634
3641
  if (config.current) {
3635
3642
  config.current.assert.pushResult({
3636
3643
  result: false,
3637
- message: "global failure: ".concat(errorString2(error)),
3644
+ message: "global failure: ".concat(errorString(error)),
3638
3645
  // We could let callers specify an offset to subtract a number of frames via
3639
3646
  // sourceFromStacktrace, in case they are a wrapper further away from the error
3640
3647
  // handler, and thus reduce some noise in the stack trace. However, we're not
@@ -3665,7 +3672,7 @@ var require_qunit = __commonJS({
3665
3672
  var DIFF_DELETE = -1;
3666
3673
  var DIFF_INSERT = 1;
3667
3674
  var DIFF_EQUAL = 0;
3668
- var hasOwn2 = Object.prototype.hasOwnProperty;
3675
+ var hasOwn = Object.prototype.hasOwnProperty;
3669
3676
  DiffMatchPatch.prototype.DiffMain = function(text1, text2, optChecklines) {
3670
3677
  var deadline = Date.now() + 1e3;
3671
3678
  if (text1 === null || text2 === null) {
@@ -4159,7 +4166,7 @@ var require_qunit = __commonJS({
4159
4166
  }
4160
4167
  var line = text.substring(lineStart, lineEnd + 1);
4161
4168
  lineStart = lineEnd + 1;
4162
- if (hasOwn2.call(lineHash, line)) {
4169
+ if (hasOwn.call(lineHash, line)) {
4163
4170
  chars += String.fromCharCode(lineHash[line]);
4164
4171
  } else {
4165
4172
  chars += String.fromCharCode(lineArrayLength);
@@ -4289,7 +4296,7 @@ var require_qunit = __commonJS({
4289
4296
  var globalStartCalled = false;
4290
4297
  var runStarted = false;
4291
4298
  QUnit.isLocal = window$1 && window$1.location && window$1.location.protocol === "file:";
4292
- QUnit.version = "2.25.0";
4299
+ QUnit.version = "2.26.0";
4293
4300
  extend(QUnit, {
4294
4301
  config,
4295
4302
  diff: diff2,
@@ -4298,7 +4305,7 @@ var require_qunit = __commonJS({
4298
4305
  reporters,
4299
4306
  hooks,
4300
4307
  is,
4301
- objectType: objectType2,
4308
+ objectType,
4302
4309
  on,
4303
4310
  onError: onWindowError,
4304
4311
  onUncaughtException,
@@ -4453,9 +4460,9 @@ var require_qunit = __commonJS({
4453
4460
  return;
4454
4461
  }
4455
4462
  var config2 = QUnit.config;
4456
- var hasOwn3 = Object.prototype.hasOwnProperty;
4463
+ var hasOwn2 = Object.prototype.hasOwnProperty;
4457
4464
  function storeFixture() {
4458
- if (hasOwn3.call(config2, "fixture")) {
4465
+ if (hasOwn2.call(config2, "fixture")) {
4459
4466
  return;
4460
4467
  }
4461
4468
  var fixture = document.getElementById("qunit-fixture");
@@ -5237,7 +5244,7 @@ var require_qunit = __commonJS({
5237
5244
  var config2 = QUnit.config;
5238
5245
  var hiddenTests = [];
5239
5246
  var collapseNext = false;
5240
- var hasOwn3 = Object.prototype.hasOwnProperty;
5247
+ var hasOwn2 = Object.prototype.hasOwnProperty;
5241
5248
  var unfilteredUrl = setUrl({
5242
5249
  filter: void 0,
5243
5250
  module: void 0,
@@ -5332,7 +5339,7 @@ var require_qunit = __commonJS({
5332
5339
  }
5333
5340
  } else {
5334
5341
  for (var _j in val.value) {
5335
- if (hasOwn3.call(val.value, _j)) {
5342
+ if (hasOwn2.call(val.value, _j)) {
5336
5343
  urlConfigHtml += "<option value='" + escapeText(_j) + "'" + (config2[val.id] === _j ? (selection = true) && " selected='selected'" : "") + ">" + escapeText(val.value[_j]) + "</option>";
5337
5344
  }
5338
5345
  }
@@ -5394,7 +5401,7 @@ var require_qunit = __commonJS({
5394
5401
  var location = window$1.location;
5395
5402
  params = extend(extend({}, QUnit.urlParams), params);
5396
5403
  for (var key in params) {
5397
- if (hasOwn3.call(params, key) && params[key] !== void 0) {
5404
+ if (hasOwn2.call(params, key) && params[key] !== void 0) {
5398
5405
  var arrValue = [].concat(params[key]);
5399
5406
  for (var i = 0; i < arrValue.length; i++) {
5400
5407
  querystring += encodeURIComponent(key);
@@ -5918,7 +5925,7 @@ var require_qunit = __commonJS({
5918
5925
  if (!testItem) {
5919
5926
  return;
5920
5927
  }
5921
- var message = escapeText(errorString2(error));
5928
+ var message = escapeText(errorString(error));
5922
5929
  message = "<span class='test-message'>" + message + "</span>";
5923
5930
  if (error && error.stack) {
5924
5931
  message += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText(error.stack) + "</pre></td></tr></table>";
@@ -5963,7 +5970,9 @@ var require_qunit = __commonJS({
5963
5970
  return ret;
5964
5971
  };
5965
5972
  window$1.addEventListener("unhandledrejection", function(event) {
5966
- QUnit.onUncaughtException(event.reason);
5973
+ if (!QUnit.config.ignoreUnhandledRejections) {
5974
+ QUnit.onUncaughtException(event.reason);
5975
+ }
5967
5976
  });
5968
5977
  })();
5969
5978
  })();
@@ -5974,7 +5983,7 @@ var require_qunit = __commonJS({
5974
5983
  });
5975
5984
 
5976
5985
  // shims/deno/index.ts
5977
- var import_qunit2 = __toESM(require_qunit(), 1);
5986
+ var import_qunit = __toESM(require_qunit(), 1);
5978
5987
 
5979
5988
  // jsr:https://jsr.io/@std/assert/1.0.19/assertion_error.ts
5980
5989
  var AssertionError = class extends Error {
@@ -6020,899 +6029,11 @@ var ANSI_PATTERN = new RegExp(
6020
6029
  "g"
6021
6030
  );
6022
6031
 
6023
- // shims/shared/assert.ts
6024
- var import_qunit = __toESM(require_qunit(), 1);
6025
-
6026
- // shims/shared/index.ts
6027
- var hasOwn = Object.prototype.hasOwnProperty;
6028
- var objToString = Object.prototype.toString;
6029
- function objectType(obj) {
6030
- if (obj === null) return "null";
6031
- const t = typeof obj;
6032
- switch (t) {
6033
- case "undefined":
6034
- case "string":
6035
- case "boolean":
6036
- case "function":
6037
- case "symbol":
6038
- case "bigint":
6039
- return t;
6040
- case "number":
6041
- return obj !== obj ? "nan" : "number";
6042
- }
6043
- const type = objToString.call(obj).slice(8, -1);
6044
- switch (type) {
6045
- case "Number":
6046
- return isNaN(obj) ? "nan" : "number";
6047
- case "String":
6048
- case "Boolean":
6049
- case "Array":
6050
- case "Set":
6051
- case "Map":
6052
- case "Date":
6053
- case "RegExp":
6054
- case "Function":
6055
- case "Symbol":
6056
- return type.toLowerCase();
6057
- default:
6058
- return "object";
6059
- }
6060
- }
6061
- function objectValues(obj, allowArray = true) {
6062
- const vals = allowArray && Array.isArray(obj) ? [] : {};
6063
- for (const key in obj) {
6064
- if (hasOwn.call(obj, key)) {
6065
- const val = obj[key];
6066
- const t = typeof val;
6067
- const isObjectish = val !== null && (t === "object" || t === "function");
6068
- vals[key] = isObjectish ? objectValues(val, allowArray) : val;
6069
- }
6070
- }
6071
- return vals;
6072
- }
6073
- function objectValuesSubset(obj, model) {
6074
- if (obj === null) return obj;
6075
- const objT = typeof obj;
6076
- if (objT !== "object" && objT !== "function") return obj;
6077
- const subset = {};
6078
- for (const key in model) {
6079
- if (hasOwn.call(model, key) && hasOwn.call(obj, key)) {
6080
- subset[key] = objectValuesSubset(
6081
- obj[key],
6082
- model[key]
6083
- );
6084
- }
6085
- }
6086
- return subset;
6087
- }
6088
- function validateExpectedExceptionArgs(expected, message, assertionMethod) {
6089
- const expectedType = objectType(expected);
6090
- if (expectedType === "string") {
6091
- if (message === void 0) {
6092
- message = expected;
6093
- expected = void 0;
6094
- return [expected, message];
6095
- } else {
6096
- throw new Error(
6097
- `assert.${assertionMethod} does not accept a string value for the expected argument.
6098
- Use a non-string object value (e.g. RegExp or validator function) instead if necessary.`
6099
- );
6100
- }
6101
- }
6102
- const valid = !expected || expectedType === "regexp" || expectedType === "function" || expectedType === "object";
6103
- if (!valid) {
6104
- throw new Error(`Invalid expected value type (${expectedType}) provided to assert.${assertionMethod}.`);
6105
- }
6106
- return [expected, message];
6107
- }
6108
- function validateException(actual, expected, message) {
6109
- let result = false;
6110
- const expectedType = objectType(expected);
6111
- if (!expected) {
6112
- result = true;
6113
- } else if (expectedType === "regexp") {
6114
- result = expected.test(errorString(actual));
6115
- expected = String(expected);
6116
- } else if (expectedType === "function" && expected.prototype !== void 0 && actual instanceof expected) {
6117
- result = true;
6118
- } else if (expectedType === "object") {
6119
- result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;
6120
- expected = errorString(expected);
6121
- } else if (expectedType === "function") {
6122
- try {
6123
- result = expected.call({}, actual) === true;
6124
- expected = null;
6125
- } catch (e) {
6126
- expected = errorString(e);
6127
- }
6128
- }
6129
- return [result, expected, message];
6130
- }
6131
- function errorString(error) {
6132
- const resultErrorString = String(error);
6133
- if (resultErrorString.slice(0, 7) === "[object") {
6134
- const name = error.name || "Error";
6135
- const msg = error.message;
6136
- return msg ? `${name}: ${msg}` : name;
6137
- }
6138
- return resultErrorString;
6139
- }
6140
-
6141
- // shims/shared/assert.ts
6142
- var PENDING = /* @__PURE__ */ Symbol("pending");
6143
- var Assert = class _Assert {
6144
- /** @internal Set by each runtime shim before tests run. */
6145
- static QUnit;
6146
- /** @internal Set by each runtime shim before tests run. */
6147
- static AssertionError;
6148
- /** @internal Set by each runtime shim before tests run. */
6149
- static inspect;
6150
- /** @internal Mutable test state written during the test run. */
6151
- test;
6152
- /** @internal */
6153
- constructor(module2, test3) {
6154
- this.test = test3 || module2.testContext;
6155
- }
6156
- /**
6157
- * Sets the number of milliseconds after which the current test will fail if not yet complete.
6158
- *
6159
- * @param {number} number - Timeout in milliseconds (positive integer).
6160
- * @example
6161
- * ```js
6162
- * test("slow async operation", async (assert) => {
6163
- * assert.timeout(500);
6164
- * await somethingAsync();
6165
- * assert.ok(true);
6166
- * });
6167
- * ```
6168
- */
6169
- timeout(number) {
6170
- if (!Number.isInteger(number) || number < 0) {
6171
- throw new Error("assert.timeout() expects a positive integer.");
6172
- }
6173
- this.test.timeout = number;
6174
- this.test.setTimeoutDuration(number);
6175
- }
6176
- /**
6177
- * Records a named step. Use with {@linkcode Assert.prototype.verifySteps} to assert that
6178
- * a sequence of steps occurred in the right order.
6179
- *
6180
- * @param {string} message - The step label to record.
6181
- * @example
6182
- * ```js
6183
- * test("event order", (assert) => {
6184
- * assert.expect(3);
6185
- * assert.step("step one");
6186
- * assert.step("step two");
6187
- * assert.verifySteps(["step one", "step two"]);
6188
- * });
6189
- * ```
6190
- */
6191
- step(message) {
6192
- this.test.steps.push(message);
6193
- const result = typeof message === "string" && message.length > 0;
6194
- const assertionMessage = result ? message : message === void 0 || message === "" ? "You must provide a message to assert.step" : "You must provide a string value to assert.step";
6195
- this.pushResult({ result, message: assertionMessage });
6196
- }
6197
- /**
6198
- * Asserts that the steps recorded via {@linkcode Assert.prototype.step} match the given array,
6199
- * then clears the recorded steps.
6200
- *
6201
- * @param {string[]} steps - Expected array of step labels in order.
6202
- * @param {string} [message] - Optional failure message.
6203
- * @example
6204
- * ```js
6205
- * test("lifecycle order", (assert) => {
6206
- * assert.step("init");
6207
- * assert.step("run");
6208
- * assert.verifySteps(["init", "run"]);
6209
- * });
6210
- * ```
6211
- */
6212
- verifySteps(steps, message = "Verify steps failed!") {
6213
- this.deepEqual(this.test.steps, steps, message);
6214
- this.test.steps.length = 0;
6215
- }
6216
- /**
6217
- * Sets the number of assertions expected to run in the current test.
6218
- * The test fails if a different number of assertions actually ran.
6219
- *
6220
- * @param {number} number - Expected assertion count (non-negative integer).
6221
- * @example
6222
- * ```js
6223
- * test("exactly two assertions", (assert) => {
6224
- * assert.expect(2);
6225
- * assert.ok(true);
6226
- * assert.ok(true);
6227
- * });
6228
- * ```
6229
- */
6230
- expect(number) {
6231
- if (!Number.isInteger(number) || number < 0) {
6232
- throw new Error("assert.expect() expects a positive integer.");
6233
- }
6234
- this.test.expectedAssertionCount = number;
6235
- }
6236
- /**
6237
- * Returns a `done` callback for callback-style async tests. The test will not
6238
- * finish until every `done` callback returned by `async()` has been called.
6239
- *
6240
- * For `async/await` tests prefer `async (assert) => { ... }` directly.
6241
- *
6242
- * @returns {function} A callback to invoke when the async work finishes.
6243
- * @example
6244
- * ```js
6245
- * test("async callback style", (assert) => {
6246
- * const done = assert.async();
6247
- * setTimeout(() => {
6248
- * assert.ok(true, "async callback ran");
6249
- * done();
6250
- * }, 10);
6251
- * });
6252
- * ```
6253
- */
6254
- async() {
6255
- const { promise, resolve } = Promise.withResolvers();
6256
- this.test.asyncOps.push(promise);
6257
- return resolve;
6258
- }
6259
- /** @internal Used by the test runner to wait for all async operations to complete. */
6260
- waitForAsyncOps() {
6261
- return Promise.all(this.test.asyncOps);
6262
- }
6263
- /**
6264
- * Pushes a custom assertion result. Fails the test if `resultInfo.result` is falsy.
6265
- * Throws an {@linkcode AssertionError} on failure.
6266
- *
6267
- * Useful for building custom assertion helpers.
6268
- *
6269
- * @param {{ result: boolean, actual?: unknown, expected?: unknown, message?: string }} resultInfo
6270
- * @example
6271
- * ```js
6272
- * test("custom assertion", (assert) => {
6273
- * assert.pushResult({
6274
- * result: 1 + 1 === 2,
6275
- * actual: 2,
6276
- * expected: 2,
6277
- * message: "custom math check",
6278
- * });
6279
- * });
6280
- * ```
6281
- */
6282
- pushResult(resultInfo = {}) {
6283
- this.test.totalExecutedAssertions++;
6284
- if (!resultInfo.result) {
6285
- throw new _Assert.AssertionError({
6286
- actual: resultInfo.actual,
6287
- expected: resultInfo.expected,
6288
- message: resultInfo.message || "Custom assertion failed!",
6289
- stackStartFn: this.pushResult
6290
- });
6291
- }
6292
- return this;
6293
- }
6294
- /**
6295
- * Asserts that `state` is truthy.
6296
- *
6297
- * @param {unknown} state - The value to test.
6298
- * @param {string} [message] - Optional failure message.
6299
- * @example
6300
- * ```js
6301
- * assert.ok(true);
6302
- * assert.ok(1, "non-zero is truthy");
6303
- * assert.ok("hello");
6304
- * ```
6305
- */
6306
- ok(state, message) {
6307
- this.test.totalExecutedAssertions++;
6308
- if (!state) {
6309
- throw new _Assert.AssertionError({
6310
- actual: state,
6311
- expected: true,
6312
- message: message || `Expected argument to be truthy, it was: ${inspect(state)}`,
6313
- stackStartFn: this.ok
6314
- });
6315
- }
6316
- }
6317
- /**
6318
- * Asserts that `state` is falsy.
6319
- *
6320
- * @param {unknown} state - The value to test.
6321
- * @param {string} [message] - Optional failure message.
6322
- * @example
6323
- * ```js
6324
- * assert.notOk(false);
6325
- * assert.notOk(0, "zero is falsy");
6326
- * assert.notOk(null);
6327
- * ```
6328
- */
6329
- notOk(state, message) {
6330
- this.test.totalExecutedAssertions++;
6331
- if (state) {
6332
- throw new _Assert.AssertionError({
6333
- actual: state,
6334
- expected: false,
6335
- message: message || `Expected argument to be falsy, it was: ${inspect(state)}`,
6336
- stackStartFn: this.notOk
6337
- });
6338
- }
6339
- }
6340
- /**
6341
- * Asserts that `state === true` (strict boolean true).
6342
- *
6343
- * @param {unknown} state - The value to test.
6344
- * @param {string} [message] - Optional failure message.
6345
- * @example
6346
- * ```js
6347
- * assert.true(1 === 1);
6348
- * assert.true(Array.isArray([]), "arrays are arrays");
6349
- * ```
6350
- */
6351
- true(state, message) {
6352
- this.test.totalExecutedAssertions++;
6353
- if (state !== true) {
6354
- throw new _Assert.AssertionError({
6355
- actual: state,
6356
- expected: true,
6357
- message: message || `Expected argument to be true, it was: ${inspect(state)}`,
6358
- stackStartFn: this.true
6359
- });
6360
- }
6361
- }
6362
- /**
6363
- * Asserts that `state === false` (strict boolean false).
6364
- *
6365
- * @param {unknown} state - The value to test.
6366
- * @param {string} [message] - Optional failure message.
6367
- * @example
6368
- * ```js
6369
- * assert.false(1 === 2);
6370
- * assert.false(Number.isNaN(42), "42 is not NaN");
6371
- * ```
6372
- */
6373
- false(state, message) {
6374
- this.test.totalExecutedAssertions++;
6375
- if (state !== false) {
6376
- throw new _Assert.AssertionError({
6377
- actual: state,
6378
- expected: false,
6379
- message: message || `Expected argument to be false, it was: ${inspect(state)}`,
6380
- stackStartFn: this.false
6381
- });
6382
- }
6383
- }
6384
- /**
6385
- * Asserts that `actual == expected` (loose equality, allows type coercion).
6386
- *
6387
- * Prefer {@linkcode Assert.prototype.strictEqual} for most comparisons. Use {@linkcode Assert.prototype.notEqual}
6388
- * for the inverse.
6389
- *
6390
- * @param {unknown} actual - The value produced by the code under test.
6391
- * @param {unknown} expected - The expected value.
6392
- * @param {string} [message] - Optional failure message.
6393
- * @example
6394
- * ```js
6395
- * assert.equal(1, 1);
6396
- * assert.equal("1", 1, "loose equality allows coercion");
6397
- * ```
6398
- */
6399
- equal(actual, expected, message) {
6400
- this.test.totalExecutedAssertions++;
6401
- if (actual != expected) {
6402
- throw new _Assert.AssertionError({
6403
- actual,
6404
- expected,
6405
- message: message || `Values are not equal:${formatDiff(actual, expected)}`,
6406
- operator: "==",
6407
- stackStartFn: this.equal
6408
- });
6409
- }
6410
- }
6411
- /**
6412
- * Asserts that `actual != expected` (loose inequality). Inverse of {@linkcode Assert.prototype.equal}.
6413
- *
6414
- * @param {unknown} actual - The actual value.
6415
- * @param {unknown} expected - The value it should not loosely equal.
6416
- * @param {string} [message] - Optional failure message.
6417
- * @example
6418
- * ```js
6419
- * assert.notEqual(1, 2);
6420
- * assert.notEqual("hello", "world");
6421
- * ```
6422
- */
6423
- notEqual(actual, expected, message) {
6424
- this.test.totalExecutedAssertions++;
6425
- if (actual == expected) {
6426
- throw new _Assert.AssertionError({
6427
- actual,
6428
- expected,
6429
- operator: "!=",
6430
- message: message || `Values are unexpectedly equal:${formatUnexpectedMatch(actual)}`,
6431
- stackStartFn: this.notEqual
6432
- });
6433
- }
6434
- }
6435
- /**
6436
- * Asserts that `actual` and `expected` have the same own enumerable properties
6437
- * and values. Prototype methods are ignored; only own properties are compared.
6438
- *
6439
- * @param {object} actual - The actual object.
6440
- * @param {object} expected - The expected object.
6441
- * @param {string} [message] - Optional failure message.
6442
- * @example
6443
- * ```js
6444
- * assert.propEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
6445
- *
6446
- * // Ignores prototype methods — only own properties matter:
6447
- * function Point(x, y) { this.x = x; this.y = y; }
6448
- * assert.propEqual(new Point(1, 2), { x: 1, y: 2 });
6449
- * ```
6450
- */
6451
- propEqual(actual, expected, message) {
6452
- this.test.totalExecutedAssertions++;
6453
- const targetActual = objectValues(actual);
6454
- const targetExpected = objectValues(expected);
6455
- if (!_Assert.QUnit.equiv(targetActual, targetExpected)) {
6456
- throw new _Assert.AssertionError({
6457
- actual: targetActual,
6458
- expected: targetExpected,
6459
- message: message || `Own properties are not equal:${formatDiff(targetActual, targetExpected)}`,
6460
- stackStartFn: this.propEqual
6461
- });
6462
- }
6463
- }
6464
- /**
6465
- * Asserts that `actual` and `expected` do NOT have the same own enumerable
6466
- * properties and values. Inverse of {@linkcode Assert.prototype.propEqual}.
6467
- *
6468
- * @param {object} actual - The actual object.
6469
- * @param {object} expected - The value it should not propEqual.
6470
- * @param {string} [message] - Optional failure message.
6471
- * @example
6472
- * ```js
6473
- * assert.notPropEqual({ a: 1 }, { a: 2 });
6474
- * assert.notPropEqual({ a: 1, b: 2 }, { a: 1 }); // extra key makes them unequal
6475
- * ```
6476
- */
6477
- notPropEqual(actual, expected, message) {
6478
- this.test.totalExecutedAssertions++;
6479
- const targetActual = objectValues(actual);
6480
- const targetExpected = objectValues(expected);
6481
- if (_Assert.QUnit.equiv(targetActual, targetExpected)) {
6482
- throw new _Assert.AssertionError({
6483
- actual: targetActual,
6484
- expected: targetExpected,
6485
- message: message || `Own properties are unexpectedly equal:${formatUnexpectedMatch(targetActual)}`,
6486
- stackStartFn: this.notPropEqual
6487
- });
6488
- }
6489
- }
6490
- /**
6491
- * Asserts that `actual` contains all own enumerable properties from `expected`
6492
- * with matching values. Extra properties on `actual` are allowed and ignored.
6493
- *
6494
- * @param {object} actual - The actual object (may have extra keys).
6495
- * @param {object} expected - The subset of key/value pairs that must be present.
6496
- * @param {string} [message] - Optional failure message.
6497
- * @example
6498
- * ```js
6499
- * assert.propContains({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
6500
- * assert.propContains(user, { role: "admin" });
6501
- * ```
6502
- */
6503
- propContains(actual, expected, message) {
6504
- this.test.totalExecutedAssertions++;
6505
- const targetActual = objectValuesSubset(actual, expected);
6506
- const targetExpected = objectValues(expected, false);
6507
- if (!_Assert.QUnit.equiv(targetActual, targetExpected)) {
6508
- throw new _Assert.AssertionError({
6509
- actual: targetActual,
6510
- expected: targetExpected,
6511
- message: message || `Object does not contain expected properties:${formatDiff(targetActual, targetExpected)}`,
6512
- stackStartFn: this.propContains
6513
- });
6514
- }
6515
- }
6516
- /**
6517
- * Asserts that `actual` does NOT contain all own enumerable properties
6518
- * from `expected` with matching values. Inverse of {@linkcode Assert.prototype.propContains}.
6519
- *
6520
- * @param {object} actual - The actual object.
6521
- * @param {object} expected - The subset of properties that must NOT all match.
6522
- * @param {string} [message] - Optional failure message.
6523
- * @example
6524
- * ```js
6525
- * assert.notPropContains({ a: 1, b: 2 }, { a: 9 });
6526
- * assert.notPropContains(user, { role: "banned" });
6527
- * ```
6528
- */
6529
- notPropContains(actual, expected, message) {
6530
- this.test.totalExecutedAssertions++;
6531
- const targetActual = objectValuesSubset(actual, expected);
6532
- const targetExpected = objectValues(expected);
6533
- if (_Assert.QUnit.equiv(targetActual, targetExpected)) {
6534
- throw new _Assert.AssertionError({
6535
- actual: targetActual,
6536
- expected: targetExpected,
6537
- message: message || `Object unexpectedly contains all expected properties:${formatUnexpectedMatch(targetActual)}`,
6538
- stackStartFn: this.notPropContains
6539
- });
6540
- }
6541
- }
6542
- /**
6543
- * Asserts deep equality between `actual` and `expected` using recursive structural
6544
- * comparison. Handles nested objects, arrays, `Date`, `RegExp`, and more.
6545
- *
6546
- * @param {unknown} actual - The actual value.
6547
- * @param {unknown} expected - The expected value.
6548
- * @param {string} [message] - Optional failure message.
6549
- * @example
6550
- * ```js
6551
- * assert.deepEqual([1, { a: 2 }], [1, { a: 2 }]);
6552
- * assert.deepEqual(new Date("2024-01-01"), new Date("2024-01-01"));
6553
- * ```
6554
- */
6555
- deepEqual(actual, expected, message) {
6556
- this.test.totalExecutedAssertions++;
6557
- if (!_Assert.QUnit.equiv(actual, expected)) {
6558
- throw new _Assert.AssertionError({
6559
- actual,
6560
- expected,
6561
- message: message || `Values are not deeply equal:${formatDiff(actual, expected)}`,
6562
- operator: "deepEqual",
6563
- stackStartFn: this.deepEqual
6564
- });
6565
- }
6566
- }
6567
- /**
6568
- * Asserts that `actual` and `expected` are NOT deeply equal. Inverse of {@linkcode Assert.prototype.deepEqual}.
6569
- *
6570
- * @param {unknown} actual - The actual value.
6571
- * @param {unknown} expected - The value it should not deepEqual.
6572
- * @param {string} [message] - Optional failure message.
6573
- * @example
6574
- * ```js
6575
- * assert.notDeepEqual([1, 2], [1, 3]);
6576
- * assert.notDeepEqual({ a: 1 }, { a: 2 });
6577
- * ```
6578
- */
6579
- notDeepEqual(actual, expected, message) {
6580
- this.test.totalExecutedAssertions++;
6581
- if (_Assert.QUnit.equiv(actual, expected)) {
6582
- throw new _Assert.AssertionError({
6583
- actual,
6584
- expected,
6585
- message: message || `Values are unexpectedly deeply equal:${formatUnexpectedMatch(actual)}`,
6586
- operator: "notDeepEqual",
6587
- stackStartFn: this.notDeepEqual
6588
- });
6589
- }
6590
- }
6591
- /**
6592
- * Asserts that `actual === expected` (strict equality, no type coercion).
6593
- *
6594
- * @param {unknown} actual - The actual value.
6595
- * @param {unknown} expected - The expected value.
6596
- * @param {string} [message] - Optional failure message.
6597
- * @example
6598
- * ```js
6599
- * assert.strictEqual(1 + 1, 2);
6600
- * assert.strictEqual(typeof "hello", "string");
6601
- * ```
6602
- */
6603
- strictEqual(actual, expected, message) {
6604
- this.test.totalExecutedAssertions++;
6605
- if (actual !== expected) {
6606
- throw new _Assert.AssertionError({
6607
- actual,
6608
- expected,
6609
- message: message || `Values are not strictly equal:${formatDiff(actual, expected)}`,
6610
- operator: "strictEqual",
6611
- stackStartFn: this.strictEqual
6612
- });
6613
- }
6614
- }
6615
- /**
6616
- * Asserts that `actual !== expected` (strict inequality). Inverse of {@linkcode Assert.prototype.strictEqual}.
6617
- *
6618
- * @param {unknown} actual - The actual value.
6619
- * @param {unknown} expected - The value it should not strictly equal.
6620
- * @param {string} [message] - Optional failure message.
6621
- * @example
6622
- * ```js
6623
- * assert.notStrictEqual(1, "1", "different types");
6624
- * assert.notStrictEqual({}, {}, "different object references");
6625
- * ```
6626
- */
6627
- notStrictEqual(actual, expected, message) {
6628
- this.test.totalExecutedAssertions++;
6629
- if (actual === expected) {
6630
- throw new _Assert.AssertionError({
6631
- actual,
6632
- expected,
6633
- message: message || `Values are unexpectedly strictly equal:${formatUnexpectedMatch(actual)}`,
6634
- operator: "notStrictEqual",
6635
- stackStartFn: this.notStrictEqual
6636
- });
6637
- }
6638
- }
6639
- /**
6640
- * Asserts that `blockFn` throws an exception. Optionally validates the thrown
6641
- * error against a string (message substring), RegExp (message pattern),
6642
- * or constructor (`instanceof` check). For async functions use {@linkcode Assert.prototype.rejects}.
6643
- *
6644
- * @param {function} blockFn - A synchronous function expected to throw.
6645
- * @param {string|RegExp|function} [expected] - Optional matcher for the thrown error.
6646
- * @param {string} [message] - Optional failure message.
6647
- * @example
6648
- * ```js
6649
- * assert.throws(() => { throw new Error("boom"); });
6650
- * assert.throws(() => JSON.parse("{bad}"), SyntaxError);
6651
- * assert.throws(() => { throw new Error("bad input"); }, /bad input/);
6652
- * ```
6653
- */
6654
- throws(blockFn, expectedInput, assertionMessage) {
6655
- this.test.totalExecutedAssertions++;
6656
- const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, "throws");
6657
- if (typeof blockFn !== "function") {
6658
- throw new _Assert.AssertionError({
6659
- actual: blockFn,
6660
- expected: Function,
6661
- message: "The value provided to `assert.throws` was not a function.",
6662
- stackStartFn: this.throws
6663
- });
6664
- }
6665
- let returnValue;
6666
- try {
6667
- returnValue = blockFn();
6668
- } catch (error) {
6669
- const [result, , validatedMessage] = validateException(error, expected, message);
6670
- if (result === false) {
6671
- const expectedDesc = describeExpected(expected);
6672
- const receivedDesc = String(error);
6673
- throw new _Assert.AssertionError({
6674
- actual: receivedDesc,
6675
- expected: expectedDesc,
6676
- message: validatedMessage || throwsFailMessage("throws", expectedDesc, receivedDesc),
6677
- stackStartFn: this.throws
6678
- });
6679
- }
6680
- return;
6681
- }
6682
- if (returnValue !== null && typeof returnValue === "object" && typeof returnValue.then === "function") {
6683
- throw new _Assert.AssertionError({
6684
- actual: returnValue,
6685
- expected,
6686
- message: "Function passed to `assert.throws` returned a Promise \u2014 did you mean to use `assert.rejects`?",
6687
- stackStartFn: this.throws
6688
- });
6689
- }
6690
- throw new _Assert.AssertionError({
6691
- actual: blockFn,
6692
- expected,
6693
- message: "Function passed to `assert.throws` did not throw an exception!",
6694
- stackStartFn: this.throws
6695
- });
6696
- }
6697
- /**
6698
- * Asserts that a promise rejects. Optionally validates the rejection reason
6699
- * against a string (message substring), RegExp (message pattern),
6700
- * or constructor (`instanceof` check). For synchronous throws use {@linkcode Assert.prototype.throws}.
6701
- *
6702
- * @param {Promise<unknown>} promise - A promise expected to reject.
6703
- * @param {string|RegExp|function} [expected] - Optional matcher for the rejection reason.
6704
- * @param {string} [message] - Optional failure message.
6705
- * @example
6706
- * ```js
6707
- * await assert.rejects(Promise.reject(new Error("oops")));
6708
- * await assert.rejects(fetch("/bad-url"), TypeError);
6709
- * await assert.rejects(Promise.reject(new Error("timeout")), /timeout/);
6710
- * ```
6711
- */
6712
- async rejects(promise, expectedInput, assertionMessage) {
6713
- this.test.totalExecutedAssertions++;
6714
- const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, "rejects");
6715
- const then = promise && promise.then;
6716
- if (typeof then !== "function") {
6717
- throw new _Assert.AssertionError({
6718
- actual: promise,
6719
- expected,
6720
- message: "The value provided to `assert.rejects` was not a promise!",
6721
- stackStartFn: this.rejects
6722
- });
6723
- }
6724
- let caught = PENDING;
6725
- try {
6726
- await promise;
6727
- } catch (error) {
6728
- caught = error;
6729
- }
6730
- if (caught === PENDING) {
6731
- throw new _Assert.AssertionError({
6732
- actual: promise,
6733
- expected,
6734
- message: "The promise returned by the `assert.rejects` callback did not reject!",
6735
- stackStartFn: this.rejects
6736
- });
6737
- }
6738
- const [result, , validatedMessage] = validateException(caught, expected, message);
6739
- if (result === false) {
6740
- const expectedDesc = describeExpected(expected);
6741
- const receivedDesc = String(caught);
6742
- throw new _Assert.AssertionError({
6743
- actual: receivedDesc,
6744
- expected: expectedDesc,
6745
- message: validatedMessage || throwsFailMessage("rejects", expectedDesc, receivedDesc),
6746
- stackStartFn: this.rejects
6747
- });
6748
- }
6749
- }
6750
- };
6751
- var INSPECT_OPTIONS = { depth: 10, colors: true, compact: false };
6752
- var inspect = (value) => Assert.inspect(value, INSPECT_OPTIONS);
6753
- function formatDiff(actual, expected) {
6754
- const aStr = inspect(actual), bStr = inspect(expected);
6755
- const aLines = aStr.split("\n"), bLines = bStr.split("\n");
6756
- if (aLines.length === 1 && bLines.length === 1) return `
6757
-
6758
- Actual: ${aStr}
6759
- Expected: ${bStr}`;
6760
- const lines = lcsDiff(aLines, bLines).map(
6761
- ([t, line]) => t === "=" ? ` ${line}` : t === "-" ? `- ${line}` : `+ ${line}`
6762
- );
6763
- return `
6764
-
6765
- - Actual + Expected
6766
-
6767
- ${lines.join("\n")}`;
6768
- }
6769
- var formatUnexpectedMatch = (actual) => `
6770
-
6771
- ${inspect(actual)}`;
6772
- var describeExpected = (expected) => expected == null ? "(no pattern)" : typeof expected === "string" ? expected : typeof expected === "function" ? expected.name || String(expected) : String(expected);
6773
- var throwsFailMessage = (method, pattern, received) => `assert.${method}: thrown error did not match expected:
6774
-
6775
- Pattern: ${pattern}
6776
- Received: ${received}`;
6777
- function lcsDiff(a, b) {
6778
- const m = a.length, n = b.length;
6779
- const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
6780
- for (let i2 = 1; i2 <= m; i2++)
6781
- for (let j2 = 1; j2 <= n; j2++)
6782
- dp[i2][j2] = a[i2 - 1] === b[j2 - 1] ? dp[i2 - 1][j2 - 1] + 1 : Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
6783
- const result = [];
6784
- let i = m, j = n;
6785
- while (i > 0 || j > 0) {
6786
- if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
6787
- result.push(["=", a[i - 1]]);
6788
- i--;
6789
- j--;
6790
- } else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
6791
- result.push(["+", b[j - 1]]);
6792
- j--;
6793
- } else {
6794
- result.push(["-", a[i - 1]]);
6795
- i--;
6796
- }
6797
- }
6798
- return result.reverse();
6799
- }
6800
-
6801
- // shims/shared/filter-stack.ts
6802
- var FILTER_PATTERNS = [
6803
- /\bnode:internal\/test_runner\//,
6804
- /\bnode:async_hooks\b/
6805
- ];
6806
- function isDebugEnabled() {
6807
- try {
6808
- const proc = globalThis.process;
6809
- if (proc?.env?.QUNITX_DEBUG === "1") return true;
6810
- const deno = globalThis.Deno;
6811
- if (deno?.env?.get?.("QUNITX_DEBUG") === "1") return true;
6812
- } catch {
6813
- }
6814
- return false;
6815
- }
6816
- function filterStack(stack) {
6817
- if (!stack || isDebugEnabled()) return stack;
6818
- return stack.split("\n").filter((line) => !FILTER_PATTERNS.some((p) => p.test(line))).join("\n");
6819
- }
6820
-
6821
- // shims/shared/test-context.ts
6822
- var TestContext = class _TestContext {
6823
- static Assert;
6824
- name;
6825
- module;
6826
- asyncOps = [];
6827
- assert;
6828
- timeout;
6829
- steps = [];
6830
- expectedAssertionCount;
6831
- totalExecutedAssertions = 0;
6832
- userContext = {};
6833
- rejectTimeout;
6834
- #timeoutHandle;
6835
- #timedOut = false;
6836
- constructor(name, moduleContext) {
6837
- if (moduleContext) {
6838
- this.name = `${moduleContext.name} | ${name}`;
6839
- this.module = moduleContext;
6840
- this.module.tests.push(this);
6841
- this.assert = new _TestContext.Assert(moduleContext, this);
6842
- }
6843
- }
6844
- setTimeoutDuration(ms) {
6845
- if (this.#timeoutHandle !== void 0) {
6846
- clearTimeout(this.#timeoutHandle);
6847
- this.#timeoutHandle = void 0;
6848
- }
6849
- if (!this.rejectTimeout) return;
6850
- this.#timeoutHandle = setTimeout(() => {
6851
- this.#timedOut = true;
6852
- this.rejectTimeout(new Error(`Test timed out after ${ms}ms`));
6853
- }, ms);
6854
- }
6855
- clearTimeoutHandle() {
6856
- if (this.#timeoutHandle !== void 0) {
6857
- clearTimeout(this.#timeoutHandle);
6858
- this.#timeoutHandle = void 0;
6859
- }
6860
- }
6861
- finish() {
6862
- if (this.#timedOut) return;
6863
- if (this.steps.length > 0) {
6864
- this.assert.pushResult({
6865
- result: false,
6866
- actual: this.steps,
6867
- expected: [],
6868
- message: `Expected assert.verifySteps() to be called before end of test after using assert.step(). Unverified steps: ${this.steps.join(", ")}`
6869
- });
6870
- } else if (this.expectedAssertionCount !== void 0 && this.expectedAssertionCount !== this.totalExecutedAssertions) {
6871
- this.assert.pushResult({
6872
- result: false,
6873
- actual: this.totalExecutedAssertions,
6874
- expected: this.expectedAssertionCount,
6875
- message: `Expected ${this.expectedAssertionCount} assertions, but ${this.totalExecutedAssertions} were run for test: ${this.name}`
6876
- });
6877
- } else if (this.expectedAssertionCount === void 0 && this.totalExecutedAssertions === 0) {
6878
- this.assert.pushResult({
6879
- result: false,
6880
- actual: this.totalExecutedAssertions,
6881
- expected: "> 0",
6882
- message: `Expected at least one assertion to be run for test: ${this.name}`
6883
- });
6884
- }
6885
- }
6886
- };
6887
-
6888
- // shims/shared/module-context.ts
6889
- var ModuleContext = class _ModuleContext {
6890
- static Assert;
6891
- static currentModuleChain = [];
6892
- static get lastModule() {
6893
- const chain = this.currentModuleChain;
6894
- return chain[chain.length - 1];
6895
- }
6896
- name;
6897
- assert;
6898
- userContext;
6899
- // Internal fallback assert for modules with no direct tests
6900
- testContext = new TestContext();
6901
- moduleChain = [];
6902
- beforeEachHooks = [];
6903
- afterEachHooks = [];
6904
- tests = [];
6905
- constructor(name) {
6906
- const chain = _ModuleContext.currentModuleChain;
6907
- const parentModule = chain[chain.length - 1];
6908
- chain.push(this);
6909
- this.moduleChain = chain.slice();
6910
- this.name = parentModule ? `${parentModule.name} > ${name}` : name;
6911
- this.assert = new _ModuleContext.Assert(this);
6912
- this.userContext = parentModule ? Object.create(parentModule.userContext) : /* @__PURE__ */ Object.create(null);
6913
- return Object.freeze(this);
6914
- }
6915
- };
6032
+ // shims/deno/index.ts
6033
+ import Assert from "../shared/assert.js";
6034
+ import { filterStack } from "../shared/filter-stack.js";
6035
+ import ModuleContext3 from "../shared/module-context.js";
6036
+ import TestContext2 from "../shared/test-context.js";
6916
6037
 
6917
6038
  // jsr:https://jsr.io/@std/internal/1.0.12/assertion_state.ts
6918
6039
  var AssertionState = class {
@@ -7703,6 +6824,7 @@ describe.skip = function describeSkip(...args) {
7703
6824
  };
7704
6825
 
7705
6826
  // shims/deno/module.ts
6827
+ import ModuleContext from "../shared/module-context.js";
7706
6828
  function module(moduleName, runtimeOptions, moduleContent) {
7707
6829
  const targetRuntimeOptions = moduleContent ? runtimeOptions : {};
7708
6830
  const { skip: skip2 } = targetRuntimeOptions;
@@ -7762,10 +6884,13 @@ module.todo = function todoModule(moduleName, _moduleContent) {
7762
6884
  describe(moduleName, { ignore: true }, function() {
7763
6885
  });
7764
6886
  };
6887
+ var module_default = module;
7765
6888
 
7766
6889
  // shims/deno/test.ts
6890
+ import ModuleContext2 from "../shared/module-context.js";
6891
+ import TestContext from "../shared/test-context.js";
7767
6892
  function test2(testName, runtimeOptions, testContent) {
7768
- const moduleContext = ModuleContext.lastModule;
6893
+ const moduleContext = ModuleContext2.lastModule;
7769
6894
  if (!moduleContext) {
7770
6895
  throw new Error(`Test '${testName}' called outside of module context.`);
7771
6896
  }
@@ -7818,9 +6943,19 @@ test2.todo = function todoTest(testName, _testContent) {
7818
6943
  it(testName, { ignore: true }, async function() {
7819
6944
  });
7820
6945
  };
6946
+ var test_default = test2;
7821
6947
 
7822
6948
  // shims/deno/index.ts
7823
6949
  var AssertionError2 = class extends AssertionError {
6950
+ /**
6951
+ * Builds an assertion failure, trimming the stack to the caller's frame.
6952
+ *
6953
+ * @param {object} object - Failure details.
6954
+ * @param {string} [object.message] - Failure message; defaults to `"Assertion failed"`.
6955
+ * @param {Function} [object.stackStartFn] - Frames at and above this function are cut
6956
+ * from the stack, so the trace starts at the caller's assertion rather than inside
6957
+ * QUnitX.
6958
+ */
7824
6959
  constructor(object) {
7825
6960
  super(object.message ?? "Assertion failed");
7826
6961
  if (object.stackStartFn) Error.captureStackTrace(this, object.stackStartFn);
@@ -7830,25 +6965,25 @@ var AssertionError2 = class extends AssertionError {
7830
6965
  Assert.QUnit = globalThis.QUnit;
7831
6966
  Assert.AssertionError = AssertionError2;
7832
6967
  Assert.inspect = Deno.inspect;
7833
- ModuleContext.Assert = Assert;
7834
- TestContext.Assert = Assert;
6968
+ ModuleContext3.Assert = Assert;
6969
+ TestContext2.Assert = Assert;
7835
6970
  Object.freeze(Assert);
7836
- Object.freeze(ModuleContext);
7837
- Object.freeze(TestContext);
7838
- var skip = test2.skip;
7839
- var todo = test2.todo;
7840
- var index_default = { AssertionError: Assert.AssertionError, module, test: test2, config: {} };
6971
+ Object.freeze(ModuleContext3);
6972
+ Object.freeze(TestContext2);
6973
+ var skip = test_default.skip;
6974
+ var todo = test_default.todo;
6975
+ var index_default = { AssertionError: Assert.AssertionError, module: module_default, test: test_default, config: {} };
7841
6976
  export {
7842
6977
  Assert,
7843
6978
  AssertionError2 as AssertionError,
7844
6979
  index_default as default,
7845
- module,
6980
+ module_default as module,
7846
6981
  skip,
7847
- test2 as test,
6982
+ test_default as test,
7848
6983
  todo
7849
6984
  };
7850
6985
  /*!
7851
- * QUnit 2.25.0
6986
+ * QUnit 2.26.0
7852
6987
  * https://qunitjs.com/
7853
6988
  *
7854
6989
  * Copyright OpenJS Foundation and other contributors