testeranto 0.171.0 → 0.172.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.
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/App.css +13 -9
- package/dist/prebuild/App.js +99 -96
- package/dist/types/src/components/pure/ProjectPageView.test/index.d.ts +1 -2
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/testeranto/App.css +13 -9
- package/testeranto/App.js +99 -96
- package/testeranto/bundles/node/allTests/metafile.json +3 -3
- package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +352 -250
- package/testeranto/bundles/pure/allTests/metafile.json +15 -15
- package/testeranto/bundles/web/allTests/metafile.json +22 -15962
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/logs.txt +24 -24
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/logs.txt +1 -1
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/logs.txt +34 -34
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +1 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +15 -15
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/logs.txt +1 -1
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +27 -27
- package/testeranto/reportsnode_build_errors +20 -0
- package/testeranto/reportspure_build_errors +343 -0
- package/testeranto/bundles/web/allTests/chunk-RLDR6LJN.mjs +0 -1030
|
@@ -486,7 +486,7 @@ function getMessage(errorLike) {
|
|
|
486
486
|
}
|
|
487
487
|
__name(getMessage, "getMessage");
|
|
488
488
|
function flag(obj, key, value) {
|
|
489
|
-
|
|
489
|
+
let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
490
490
|
if (arguments.length === 3) {
|
|
491
491
|
flags[key] = value;
|
|
492
492
|
} else {
|
|
@@ -495,7 +495,7 @@ function flag(obj, key, value) {
|
|
|
495
495
|
}
|
|
496
496
|
__name(flag, "flag");
|
|
497
497
|
function test(obj, args) {
|
|
498
|
-
|
|
498
|
+
let negate = flag(obj, "negate"), expr = args[0];
|
|
499
499
|
return negate ? !expr : expr;
|
|
500
500
|
}
|
|
501
501
|
__name(test, "test");
|
|
@@ -549,20 +549,20 @@ var AssertionError = class _AssertionError extends Error {
|
|
|
549
549
|
}
|
|
550
550
|
};
|
|
551
551
|
function expectTypes(obj, types) {
|
|
552
|
-
|
|
553
|
-
|
|
552
|
+
let flagMsg = flag(obj, "message");
|
|
553
|
+
let ssfi = flag(obj, "ssfi");
|
|
554
554
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
555
555
|
obj = flag(obj, "object");
|
|
556
556
|
types = types.map(function(t) {
|
|
557
557
|
return t.toLowerCase();
|
|
558
558
|
});
|
|
559
559
|
types.sort();
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
let str = types.map(function(t, index) {
|
|
561
|
+
let art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a";
|
|
562
|
+
let or = types.length > 1 && index === types.length - 1 ? "or " : "";
|
|
563
563
|
return or + art + " " + t;
|
|
564
564
|
}).join(", ");
|
|
565
|
-
|
|
565
|
+
let objType = type(obj).toLowerCase();
|
|
566
566
|
if (!types.some(function(expected) {
|
|
567
567
|
return objType === expected;
|
|
568
568
|
})) {
|
|
@@ -1041,10 +1041,10 @@ try {
|
|
|
1041
1041
|
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
1042
1042
|
var stringTagMap = {};
|
|
1043
1043
|
var baseTypesMap = {
|
|
1044
|
-
undefined: (value, options) => options.stylize("undefined", "undefined"),
|
|
1045
|
-
null: (value, options) => options.stylize("null", "null"),
|
|
1046
|
-
boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1047
|
-
Boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1044
|
+
undefined: /* @__PURE__ */ __name((value, options) => options.stylize("undefined", "undefined"), "undefined"),
|
|
1045
|
+
null: /* @__PURE__ */ __name((value, options) => options.stylize("null", "null"), "null"),
|
|
1046
|
+
boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "boolean"),
|
|
1047
|
+
Boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "Boolean"),
|
|
1048
1048
|
number: inspectNumber,
|
|
1049
1049
|
Number: inspectNumber,
|
|
1050
1050
|
bigint: inspectBigInt,
|
|
@@ -1063,8 +1063,8 @@ var baseTypesMap = {
|
|
|
1063
1063
|
RegExp: inspectRegExp,
|
|
1064
1064
|
Promise: promise_default,
|
|
1065
1065
|
// WeakSet, WeakMap are totally opaque to us
|
|
1066
|
-
WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
|
|
1067
|
-
WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
|
|
1066
|
+
WeakSet: /* @__PURE__ */ __name((value, options) => options.stylize("WeakSet{\u2026}", "special"), "WeakSet"),
|
|
1067
|
+
WeakMap: /* @__PURE__ */ __name((value, options) => options.stylize("WeakMap{\u2026}", "special"), "WeakMap"),
|
|
1068
1068
|
Arguments: inspectArguments,
|
|
1069
1069
|
Int8Array: inspectTypedArray,
|
|
1070
1070
|
Uint8Array: inspectTypedArray,
|
|
@@ -1075,9 +1075,9 @@ var baseTypesMap = {
|
|
|
1075
1075
|
Uint32Array: inspectTypedArray,
|
|
1076
1076
|
Float32Array: inspectTypedArray,
|
|
1077
1077
|
Float64Array: inspectTypedArray,
|
|
1078
|
-
Generator: () => "",
|
|
1079
|
-
DataView: () => "",
|
|
1080
|
-
ArrayBuffer: () => "",
|
|
1078
|
+
Generator: /* @__PURE__ */ __name(() => "", "Generator"),
|
|
1079
|
+
DataView: /* @__PURE__ */ __name(() => "", "DataView"),
|
|
1080
|
+
ArrayBuffer: /* @__PURE__ */ __name(() => "", "ArrayBuffer"),
|
|
1081
1081
|
Error: inspectObject2,
|
|
1082
1082
|
HTMLCollection: inspectHTMLCollection,
|
|
1083
1083
|
NodeList: inspectHTMLCollection
|
|
@@ -1246,7 +1246,7 @@ var config = {
|
|
|
1246
1246
|
deepEqual: null
|
|
1247
1247
|
};
|
|
1248
1248
|
function inspect2(obj, showHidden, depth, colors) {
|
|
1249
|
-
|
|
1249
|
+
let options = {
|
|
1250
1250
|
colors,
|
|
1251
1251
|
depth: typeof depth === "undefined" ? 2 : depth,
|
|
1252
1252
|
showHidden,
|
|
@@ -1256,14 +1256,14 @@ function inspect2(obj, showHidden, depth, colors) {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
__name(inspect2, "inspect");
|
|
1258
1258
|
function objDisplay(obj) {
|
|
1259
|
-
|
|
1259
|
+
let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
|
|
1260
1260
|
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
|
1261
1261
|
if (type3 === "[object Function]") {
|
|
1262
1262
|
return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
|
|
1263
1263
|
} else if (type3 === "[object Array]") {
|
|
1264
1264
|
return "[ Array(" + obj.length + ") ]";
|
|
1265
1265
|
} else if (type3 === "[object Object]") {
|
|
1266
|
-
|
|
1266
|
+
let keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
|
|
1267
1267
|
return "{ Object (" + kstr + ") }";
|
|
1268
1268
|
} else {
|
|
1269
1269
|
return str;
|
|
@@ -1274,7 +1274,12 @@ function objDisplay(obj) {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
__name(objDisplay, "objDisplay");
|
|
1276
1276
|
function getMessage2(obj, args) {
|
|
1277
|
-
|
|
1277
|
+
let negate = flag(obj, "negate");
|
|
1278
|
+
let val = flag(obj, "object");
|
|
1279
|
+
let expected = args[3];
|
|
1280
|
+
let actual = getActual(obj, args);
|
|
1281
|
+
let msg = negate ? args[2] : args[1];
|
|
1282
|
+
let flagMsg = flag(obj, "message");
|
|
1278
1283
|
if (typeof msg === "function")
|
|
1279
1284
|
msg = msg();
|
|
1280
1285
|
msg = msg || "";
|
|
@@ -1289,12 +1294,12 @@ function getMessage2(obj, args) {
|
|
|
1289
1294
|
}
|
|
1290
1295
|
__name(getMessage2, "getMessage");
|
|
1291
1296
|
function transferFlags(assertion, object, includeAll) {
|
|
1292
|
-
|
|
1297
|
+
let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
1293
1298
|
if (!object.__flags) {
|
|
1294
1299
|
object.__flags = /* @__PURE__ */ Object.create(null);
|
|
1295
1300
|
}
|
|
1296
1301
|
includeAll = arguments.length === 3 ? includeAll : true;
|
|
1297
|
-
for (
|
|
1302
|
+
for (let flag3 in flags) {
|
|
1298
1303
|
if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
|
|
1299
1304
|
object.__flags[flag3] = flags[flag3];
|
|
1300
1305
|
}
|
|
@@ -1682,96 +1687,186 @@ function getPathInfo(obj, path) {
|
|
|
1682
1687
|
return info;
|
|
1683
1688
|
}
|
|
1684
1689
|
__name(getPathInfo, "getPathInfo");
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1690
|
+
var Assertion = class _Assertion {
|
|
1691
|
+
static {
|
|
1692
|
+
__name(this, "Assertion");
|
|
1693
|
+
}
|
|
1694
|
+
/** @type {{}} */
|
|
1695
|
+
__flags = {};
|
|
1696
|
+
/**
|
|
1697
|
+
* Creates object for chaining.
|
|
1698
|
+
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
|
1699
|
+
* be assigned during instantiation by passing arguments to this constructor:
|
|
1700
|
+
*
|
|
1701
|
+
* - `object`: This flag contains the target of the assertion. For example, in
|
|
1702
|
+
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
|
|
1703
|
+
* contain `numKittens` so that the `equal` assertion can reference it when
|
|
1704
|
+
* needed.
|
|
1705
|
+
*
|
|
1706
|
+
* - `message`: This flag contains an optional custom error message to be
|
|
1707
|
+
* prepended to the error message that's generated by the assertion when it
|
|
1708
|
+
* fails.
|
|
1709
|
+
*
|
|
1710
|
+
* - `ssfi`: This flag stands for "start stack function indicator". It
|
|
1711
|
+
* contains a function reference that serves as the starting point for
|
|
1712
|
+
* removing frames from the stack trace of the error that's created by the
|
|
1713
|
+
* assertion when it fails. The goal is to provide a cleaner stack trace to
|
|
1714
|
+
* end users by removing Chai's internal functions. Note that it only works
|
|
1715
|
+
* in environments that support `Error.captureStackTrace`, and only when
|
|
1716
|
+
* `Chai.config.includeStack` hasn't been set to `false`.
|
|
1717
|
+
*
|
|
1718
|
+
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
|
|
1719
|
+
* should retain its current value, even as assertions are chained off of
|
|
1720
|
+
* this object. This is usually set to `true` when creating a new assertion
|
|
1721
|
+
* from within another assertion. It's also temporarily set to `true` before
|
|
1722
|
+
* an overwritten assertion gets called by the overwriting assertion.
|
|
1723
|
+
*
|
|
1724
|
+
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
|
|
1725
|
+
*
|
|
1726
|
+
* @param {unknown} obj target of the assertion
|
|
1727
|
+
* @param {string} [msg] (optional) custom error message
|
|
1728
|
+
* @param {Function} [ssfi] (optional) starting point for removing stack frames
|
|
1729
|
+
* @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
|
|
1730
|
+
*/
|
|
1731
|
+
constructor(obj, msg, ssfi, lockSsfi) {
|
|
1732
|
+
flag(this, "ssfi", ssfi || _Assertion);
|
|
1733
|
+
flag(this, "lockSsfi", lockSsfi);
|
|
1734
|
+
flag(this, "object", obj);
|
|
1735
|
+
flag(this, "message", msg);
|
|
1736
|
+
flag(this, "eql", config.deepEqual || deep_eql_default);
|
|
1737
|
+
return proxify(this);
|
|
1738
|
+
}
|
|
1739
|
+
/** @returns {boolean} */
|
|
1740
|
+
static get includeStack() {
|
|
1696
1741
|
console.warn(
|
|
1697
1742
|
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1698
1743
|
);
|
|
1699
1744
|
return config.includeStack;
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1745
|
+
}
|
|
1746
|
+
/** @param {boolean} value */
|
|
1747
|
+
static set includeStack(value) {
|
|
1702
1748
|
console.warn(
|
|
1703
1749
|
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1704
1750
|
);
|
|
1705
1751
|
config.includeStack = value;
|
|
1706
1752
|
}
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
get: function() {
|
|
1753
|
+
/** @returns {boolean} */
|
|
1754
|
+
static get showDiff() {
|
|
1710
1755
|
console.warn(
|
|
1711
1756
|
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1712
1757
|
);
|
|
1713
1758
|
return config.showDiff;
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1759
|
+
}
|
|
1760
|
+
/** @param {boolean} value */
|
|
1761
|
+
static set showDiff(value) {
|
|
1716
1762
|
console.warn(
|
|
1717
1763
|
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1718
1764
|
);
|
|
1719
1765
|
config.showDiff = value;
|
|
1720
1766
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1767
|
+
/**
|
|
1768
|
+
* @param {string} name
|
|
1769
|
+
* @param {Function} fn
|
|
1770
|
+
*/
|
|
1771
|
+
static addProperty(name, fn) {
|
|
1772
|
+
addProperty(this.prototype, name, fn);
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* @param {string} name
|
|
1776
|
+
* @param {Function} fn
|
|
1777
|
+
*/
|
|
1778
|
+
static addMethod(name, fn) {
|
|
1779
|
+
addMethod(this.prototype, name, fn);
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* @param {string} name
|
|
1783
|
+
* @param {Function} fn
|
|
1784
|
+
* @param {Function} chainingBehavior
|
|
1785
|
+
*/
|
|
1786
|
+
static addChainableMethod(name, fn, chainingBehavior) {
|
|
1787
|
+
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* @param {string} name
|
|
1791
|
+
* @param {Function} fn
|
|
1792
|
+
*/
|
|
1793
|
+
static overwriteProperty(name, fn) {
|
|
1794
|
+
overwriteProperty(this.prototype, name, fn);
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* @param {string} name
|
|
1798
|
+
* @param {Function} fn
|
|
1799
|
+
*/
|
|
1800
|
+
static overwriteMethod(name, fn) {
|
|
1801
|
+
overwriteMethod(this.prototype, name, fn);
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* @param {string} name
|
|
1805
|
+
* @param {Function} fn
|
|
1806
|
+
* @param {Function} chainingBehavior
|
|
1807
|
+
*/
|
|
1808
|
+
static overwriteChainableMethod(name, fn, chainingBehavior) {
|
|
1809
|
+
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* ### .assert(expression, message, negateMessage, expected, actual, showDiff)
|
|
1813
|
+
*
|
|
1814
|
+
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
|
|
1815
|
+
*
|
|
1816
|
+
* @name assert
|
|
1817
|
+
* @param {unknown} _expr to be tested
|
|
1818
|
+
* @param {string | Function} msg or function that returns message to display if expression fails
|
|
1819
|
+
* @param {string | Function} _negateMsg or function that returns negatedMessage to display if negated expression fails
|
|
1820
|
+
* @param {unknown} expected value (remember to check for negation)
|
|
1821
|
+
* @param {unknown} _actual (optional) will default to `this.obj`
|
|
1822
|
+
* @param {boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
|
|
1823
|
+
* @returns {void}
|
|
1824
|
+
*/
|
|
1825
|
+
assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
|
|
1826
|
+
const ok = test(this, arguments);
|
|
1827
|
+
if (false !== showDiff)
|
|
1828
|
+
showDiff = true;
|
|
1829
|
+
if (void 0 === expected && void 0 === _actual)
|
|
1830
|
+
showDiff = false;
|
|
1831
|
+
if (true !== config.showDiff)
|
|
1832
|
+
showDiff = false;
|
|
1833
|
+
if (!ok) {
|
|
1834
|
+
msg = getMessage2(this, arguments);
|
|
1835
|
+
const actual = getActual(this, arguments);
|
|
1836
|
+
const assertionErrorObjectProperties = {
|
|
1837
|
+
actual,
|
|
1838
|
+
expected,
|
|
1839
|
+
showDiff
|
|
1840
|
+
};
|
|
1841
|
+
const operator = getOperator(this, arguments);
|
|
1842
|
+
if (operator) {
|
|
1843
|
+
assertionErrorObjectProperties.operator = operator;
|
|
1844
|
+
}
|
|
1845
|
+
throw new AssertionError(
|
|
1846
|
+
msg,
|
|
1847
|
+
assertionErrorObjectProperties,
|
|
1848
|
+
// @ts-expect-error Not sure what to do about these types yet
|
|
1849
|
+
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1850
|
+
);
|
|
1759
1851
|
}
|
|
1760
|
-
throw new AssertionError(
|
|
1761
|
-
msg,
|
|
1762
|
-
assertionErrorObjectProperties,
|
|
1763
|
-
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1764
|
-
);
|
|
1765
1852
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1853
|
+
/**
|
|
1854
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1855
|
+
*
|
|
1856
|
+
* @returns {unknown}
|
|
1857
|
+
*/
|
|
1858
|
+
get _obj() {
|
|
1769
1859
|
return flag(this, "object");
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1863
|
+
*
|
|
1864
|
+
* @param {unknown} val
|
|
1865
|
+
*/
|
|
1866
|
+
set _obj(val) {
|
|
1772
1867
|
flag(this, "object", val);
|
|
1773
1868
|
}
|
|
1774
|
-
}
|
|
1869
|
+
};
|
|
1775
1870
|
function isProxyEnabled() {
|
|
1776
1871
|
return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
|
|
1777
1872
|
}
|
|
@@ -1784,10 +1879,10 @@ function addProperty(ctx, name, getter) {
|
|
|
1784
1879
|
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1785
1880
|
flag(this, "ssfi", propertyGetter);
|
|
1786
1881
|
}
|
|
1787
|
-
|
|
1882
|
+
let result = getter.call(this);
|
|
1788
1883
|
if (result !== void 0)
|
|
1789
1884
|
return result;
|
|
1790
|
-
|
|
1885
|
+
let newAssertion = new Assertion();
|
|
1791
1886
|
transferFlags(this, newAssertion);
|
|
1792
1887
|
return newAssertion;
|
|
1793
1888
|
}, "propertyGetter"),
|
|
@@ -1801,7 +1896,7 @@ function addLengthGuard(fn, assertionName, isChainable) {
|
|
|
1801
1896
|
if (!fnLengthDesc.configurable)
|
|
1802
1897
|
return fn;
|
|
1803
1898
|
Object.defineProperty(fn, "length", {
|
|
1804
|
-
get: function() {
|
|
1899
|
+
get: /* @__PURE__ */ __name(function() {
|
|
1805
1900
|
if (isChainable) {
|
|
1806
1901
|
throw Error(
|
|
1807
1902
|
"Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'
|
|
@@ -1810,20 +1905,20 @@ function addLengthGuard(fn, assertionName, isChainable) {
|
|
|
1810
1905
|
throw Error(
|
|
1811
1906
|
"Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'
|
|
1812
1907
|
);
|
|
1813
|
-
}
|
|
1908
|
+
}, "get")
|
|
1814
1909
|
});
|
|
1815
1910
|
return fn;
|
|
1816
1911
|
}
|
|
1817
1912
|
__name(addLengthGuard, "addLengthGuard");
|
|
1818
1913
|
function getProperties(object) {
|
|
1819
|
-
|
|
1914
|
+
let result = Object.getOwnPropertyNames(object);
|
|
1820
1915
|
function addProperty2(property) {
|
|
1821
1916
|
if (result.indexOf(property) === -1) {
|
|
1822
1917
|
result.push(property);
|
|
1823
1918
|
}
|
|
1824
1919
|
}
|
|
1825
1920
|
__name(addProperty2, "addProperty");
|
|
1826
|
-
|
|
1921
|
+
let proto = Object.getPrototypeOf(object);
|
|
1827
1922
|
while (proto !== null) {
|
|
1828
1923
|
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
1829
1924
|
proto = Object.getPrototypeOf(proto);
|
|
@@ -1843,15 +1938,15 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1843
1938
|
"Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".'
|
|
1844
1939
|
);
|
|
1845
1940
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1941
|
+
let suggestion = null;
|
|
1942
|
+
let suggestionDistance = 4;
|
|
1848
1943
|
getProperties(target).forEach(function(prop) {
|
|
1849
1944
|
if (
|
|
1850
1945
|
// we actually mean to check `Object.prototype` here
|
|
1851
1946
|
// eslint-disable-next-line no-prototype-builtins
|
|
1852
1947
|
!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1
|
|
1853
1948
|
) {
|
|
1854
|
-
|
|
1949
|
+
let dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
1855
1950
|
if (dist < suggestionDistance) {
|
|
1856
1951
|
suggestion = prop;
|
|
1857
1952
|
suggestionDistance = dist;
|
|
@@ -1878,7 +1973,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1878
1973
|
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
1879
1974
|
return cap;
|
|
1880
1975
|
}
|
|
1881
|
-
|
|
1976
|
+
let memo = [];
|
|
1882
1977
|
for (let i = 0; i <= strA.length; i++) {
|
|
1883
1978
|
memo[i] = Array(strB.length + 1).fill(0);
|
|
1884
1979
|
memo[i][0] = i;
|
|
@@ -1887,7 +1982,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1887
1982
|
memo[0][j] = j;
|
|
1888
1983
|
}
|
|
1889
1984
|
for (let i = 1; i <= strA.length; i++) {
|
|
1890
|
-
|
|
1985
|
+
let ch = strA.charCodeAt(i - 1);
|
|
1891
1986
|
for (let j = 1; j <= strB.length; j++) {
|
|
1892
1987
|
if (Math.abs(i - j) >= cap) {
|
|
1893
1988
|
memo[i][j] = cap;
|
|
@@ -1904,14 +1999,14 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1904
1999
|
}
|
|
1905
2000
|
__name(stringDistanceCapped, "stringDistanceCapped");
|
|
1906
2001
|
function addMethod(ctx, name, method) {
|
|
1907
|
-
|
|
2002
|
+
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1908
2003
|
if (!flag(this, "lockSsfi")) {
|
|
1909
2004
|
flag(this, "ssfi", methodWrapper);
|
|
1910
2005
|
}
|
|
1911
|
-
|
|
2006
|
+
let result = method.apply(this, arguments);
|
|
1912
2007
|
if (result !== void 0)
|
|
1913
2008
|
return result;
|
|
1914
|
-
|
|
2009
|
+
let newAssertion = new Assertion();
|
|
1915
2010
|
transferFlags(this, newAssertion);
|
|
1916
2011
|
return newAssertion;
|
|
1917
2012
|
}, "methodWrapper");
|
|
@@ -1920,7 +2015,7 @@ function addMethod(ctx, name, method) {
|
|
|
1920
2015
|
}
|
|
1921
2016
|
__name(addMethod, "addMethod");
|
|
1922
2017
|
function overwriteProperty(ctx, name, getter) {
|
|
1923
|
-
|
|
2018
|
+
let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {
|
|
1924
2019
|
}, "_super");
|
|
1925
2020
|
if (_get && "function" === typeof _get.get)
|
|
1926
2021
|
_super = _get.get;
|
|
@@ -1929,14 +2024,14 @@ function overwriteProperty(ctx, name, getter) {
|
|
|
1929
2024
|
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1930
2025
|
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1931
2026
|
}
|
|
1932
|
-
|
|
2027
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1933
2028
|
flag(this, "lockSsfi", true);
|
|
1934
|
-
|
|
2029
|
+
let result = getter(_super).call(this);
|
|
1935
2030
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1936
2031
|
if (result !== void 0) {
|
|
1937
2032
|
return result;
|
|
1938
2033
|
}
|
|
1939
|
-
|
|
2034
|
+
let newAssertion = new Assertion();
|
|
1940
2035
|
transferFlags(this, newAssertion);
|
|
1941
2036
|
return newAssertion;
|
|
1942
2037
|
}, "overwritingPropertyGetter"),
|
|
@@ -1945,23 +2040,23 @@ function overwriteProperty(ctx, name, getter) {
|
|
|
1945
2040
|
}
|
|
1946
2041
|
__name(overwriteProperty, "overwriteProperty");
|
|
1947
2042
|
function overwriteMethod(ctx, name, method) {
|
|
1948
|
-
|
|
2043
|
+
let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
1949
2044
|
throw new Error(name + " is not a function");
|
|
1950
2045
|
}, "_super");
|
|
1951
2046
|
if (_method && "function" === typeof _method)
|
|
1952
2047
|
_super = _method;
|
|
1953
|
-
|
|
2048
|
+
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1954
2049
|
if (!flag(this, "lockSsfi")) {
|
|
1955
2050
|
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1956
2051
|
}
|
|
1957
|
-
|
|
2052
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1958
2053
|
flag(this, "lockSsfi", true);
|
|
1959
|
-
|
|
2054
|
+
let result = method(_super).apply(this, arguments);
|
|
1960
2055
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1961
2056
|
if (result !== void 0) {
|
|
1962
2057
|
return result;
|
|
1963
2058
|
}
|
|
1964
|
-
|
|
2059
|
+
let newAssertion = new Assertion();
|
|
1965
2060
|
transferFlags(this, newAssertion);
|
|
1966
2061
|
return newAssertion;
|
|
1967
2062
|
}, "overwritingMethodWrapper");
|
|
@@ -1973,7 +2068,7 @@ var canSetPrototype = typeof Object.setPrototypeOf === "function";
|
|
|
1973
2068
|
var testFn = /* @__PURE__ */ __name(function() {
|
|
1974
2069
|
}, "testFn");
|
|
1975
2070
|
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
1976
|
-
|
|
2071
|
+
let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
1977
2072
|
if (typeof propDesc !== "object")
|
|
1978
2073
|
return true;
|
|
1979
2074
|
return !propDesc.configurable;
|
|
@@ -1985,7 +2080,7 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1985
2080
|
chainingBehavior = /* @__PURE__ */ __name(function() {
|
|
1986
2081
|
}, "chainingBehavior");
|
|
1987
2082
|
}
|
|
1988
|
-
|
|
2083
|
+
let chainableBehavior = {
|
|
1989
2084
|
method,
|
|
1990
2085
|
chainingBehavior
|
|
1991
2086
|
};
|
|
@@ -1996,31 +2091,31 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1996
2091
|
Object.defineProperty(ctx, name, {
|
|
1997
2092
|
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1998
2093
|
chainableBehavior.chainingBehavior.call(this);
|
|
1999
|
-
|
|
2094
|
+
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
2000
2095
|
if (!flag(this, "lockSsfi")) {
|
|
2001
2096
|
flag(this, "ssfi", chainableMethodWrapper);
|
|
2002
2097
|
}
|
|
2003
|
-
|
|
2098
|
+
let result = chainableBehavior.method.apply(this, arguments);
|
|
2004
2099
|
if (result !== void 0) {
|
|
2005
2100
|
return result;
|
|
2006
2101
|
}
|
|
2007
|
-
|
|
2102
|
+
let newAssertion = new Assertion();
|
|
2008
2103
|
transferFlags(this, newAssertion);
|
|
2009
2104
|
return newAssertion;
|
|
2010
2105
|
}, "chainableMethodWrapper");
|
|
2011
2106
|
addLengthGuard(chainableMethodWrapper, name, true);
|
|
2012
2107
|
if (canSetPrototype) {
|
|
2013
|
-
|
|
2108
|
+
let prototype = Object.create(this);
|
|
2014
2109
|
prototype.call = call;
|
|
2015
2110
|
prototype.apply = apply;
|
|
2016
2111
|
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
2017
2112
|
} else {
|
|
2018
|
-
|
|
2113
|
+
let asserterNames = Object.getOwnPropertyNames(ctx);
|
|
2019
2114
|
asserterNames.forEach(function(asserterName) {
|
|
2020
2115
|
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
2021
2116
|
return;
|
|
2022
2117
|
}
|
|
2023
|
-
|
|
2118
|
+
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
2024
2119
|
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
2025
2120
|
});
|
|
2026
2121
|
}
|
|
@@ -2032,24 +2127,24 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
2032
2127
|
}
|
|
2033
2128
|
__name(addChainableMethod, "addChainableMethod");
|
|
2034
2129
|
function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
2035
|
-
|
|
2036
|
-
|
|
2130
|
+
let chainableBehavior = ctx.__methods[name];
|
|
2131
|
+
let _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
2037
2132
|
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
2038
|
-
|
|
2133
|
+
let result = chainingBehavior(_chainingBehavior).call(this);
|
|
2039
2134
|
if (result !== void 0) {
|
|
2040
2135
|
return result;
|
|
2041
2136
|
}
|
|
2042
|
-
|
|
2137
|
+
let newAssertion = new Assertion();
|
|
2043
2138
|
transferFlags(this, newAssertion);
|
|
2044
2139
|
return newAssertion;
|
|
2045
2140
|
}, "overwritingChainableMethodGetter");
|
|
2046
|
-
|
|
2141
|
+
let _method = chainableBehavior.method;
|
|
2047
2142
|
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
2048
|
-
|
|
2143
|
+
let result = method(_method).apply(this, arguments);
|
|
2049
2144
|
if (result !== void 0) {
|
|
2050
2145
|
return result;
|
|
2051
2146
|
}
|
|
2052
|
-
|
|
2147
|
+
let newAssertion = new Assertion();
|
|
2053
2148
|
transferFlags(this, newAssertion);
|
|
2054
2149
|
return newAssertion;
|
|
2055
2150
|
}, "overwritingChainableMethodWrapper");
|
|
@@ -2073,16 +2168,16 @@ function getOwnEnumerableProperties(obj) {
|
|
|
2073
2168
|
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
2074
2169
|
var isNaN2 = Number.isNaN;
|
|
2075
2170
|
function isObjectType(obj) {
|
|
2076
|
-
|
|
2077
|
-
|
|
2171
|
+
let objectType = type(obj);
|
|
2172
|
+
let objectTypes = ["Array", "Object", "Function"];
|
|
2078
2173
|
return objectTypes.indexOf(objectType) !== -1;
|
|
2079
2174
|
}
|
|
2080
2175
|
__name(isObjectType, "isObjectType");
|
|
2081
2176
|
function getOperator(obj, args) {
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2177
|
+
let operator = flag(obj, "operator");
|
|
2178
|
+
let negate = flag(obj, "negate");
|
|
2179
|
+
let expected = args[3];
|
|
2180
|
+
let msg = negate ? args[2] : args[1];
|
|
2086
2181
|
if (operator) {
|
|
2087
2182
|
return operator;
|
|
2088
2183
|
}
|
|
@@ -2095,7 +2190,7 @@ function getOperator(obj, args) {
|
|
|
2095
2190
|
if (/\shave\s/.test(msg)) {
|
|
2096
2191
|
return void 0;
|
|
2097
2192
|
}
|
|
2098
|
-
|
|
2193
|
+
let isObject = isObjectType(expected);
|
|
2099
2194
|
if (/\snot\s/.test(msg)) {
|
|
2100
2195
|
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
2101
2196
|
}
|
|
@@ -2174,7 +2269,7 @@ function an(type3, msg) {
|
|
|
2174
2269
|
if (msg)
|
|
2175
2270
|
flag2(this, "message", msg);
|
|
2176
2271
|
type3 = type3.toLowerCase();
|
|
2177
|
-
|
|
2272
|
+
let obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
2178
2273
|
const detectedType = type(obj).toLowerCase();
|
|
2179
2274
|
if (functionTypes["function"].includes(type3)) {
|
|
2180
2275
|
this.assert(
|
|
@@ -2204,9 +2299,9 @@ __name(includeChainingBehavior, "includeChainingBehavior");
|
|
|
2204
2299
|
function include(val, msg) {
|
|
2205
2300
|
if (msg)
|
|
2206
2301
|
flag2(this, "message", msg);
|
|
2207
|
-
|
|
2302
|
+
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
|
|
2208
2303
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2209
|
-
|
|
2304
|
+
let included = false;
|
|
2210
2305
|
switch (objType) {
|
|
2211
2306
|
case "string":
|
|
2212
2307
|
included = obj.indexOf(val) !== -1;
|
|
@@ -2244,7 +2339,7 @@ function include(val, msg) {
|
|
|
2244
2339
|
included = obj.indexOf(val) !== -1;
|
|
2245
2340
|
}
|
|
2246
2341
|
break;
|
|
2247
|
-
default:
|
|
2342
|
+
default: {
|
|
2248
2343
|
if (val !== Object(val)) {
|
|
2249
2344
|
throw new AssertionError(
|
|
2250
2345
|
flagMsg + "the given combination of arguments (" + objType + " and " + type(val).toLowerCase() + ") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a " + type(val).toLowerCase(),
|
|
@@ -2252,9 +2347,11 @@ function include(val, msg) {
|
|
|
2252
2347
|
ssfi
|
|
2253
2348
|
);
|
|
2254
2349
|
}
|
|
2255
|
-
|
|
2350
|
+
let props = Object.keys(val);
|
|
2351
|
+
let firstErr = null;
|
|
2352
|
+
let numErrs = 0;
|
|
2256
2353
|
props.forEach(function(prop) {
|
|
2257
|
-
|
|
2354
|
+
let propAssertion = new Assertion(obj);
|
|
2258
2355
|
transferFlags(this, propAssertion, true);
|
|
2259
2356
|
flag2(propAssertion, "lockSsfi", true);
|
|
2260
2357
|
if (!negate || props.length === 1) {
|
|
@@ -2276,6 +2373,7 @@ function include(val, msg) {
|
|
|
2276
2373
|
throw firstErr;
|
|
2277
2374
|
}
|
|
2278
2375
|
return;
|
|
2376
|
+
}
|
|
2279
2377
|
}
|
|
2280
2378
|
this.assert(
|
|
2281
2379
|
included,
|
|
@@ -2359,7 +2457,7 @@ Assertion.addProperty("NaN", function() {
|
|
|
2359
2457
|
);
|
|
2360
2458
|
});
|
|
2361
2459
|
function assertExist() {
|
|
2362
|
-
|
|
2460
|
+
let val = flag2(this, "object");
|
|
2363
2461
|
this.assert(
|
|
2364
2462
|
val !== null && val !== void 0,
|
|
2365
2463
|
"expected #{this} to exist",
|
|
@@ -2370,7 +2468,7 @@ __name(assertExist, "assertExist");
|
|
|
2370
2468
|
Assertion.addProperty("exist", assertExist);
|
|
2371
2469
|
Assertion.addProperty("exists", assertExist);
|
|
2372
2470
|
Assertion.addProperty("empty", function() {
|
|
2373
|
-
|
|
2471
|
+
let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
2374
2472
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2375
2473
|
switch (type(val).toLowerCase()) {
|
|
2376
2474
|
case "array":
|
|
@@ -2388,9 +2486,10 @@ Assertion.addProperty("empty", function() {
|
|
|
2388
2486
|
void 0,
|
|
2389
2487
|
ssfi
|
|
2390
2488
|
);
|
|
2391
|
-
case "function":
|
|
2392
|
-
|
|
2489
|
+
case "function": {
|
|
2490
|
+
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
2393
2491
|
throw new AssertionError(msg.trim(), void 0, ssfi);
|
|
2492
|
+
}
|
|
2394
2493
|
default:
|
|
2395
2494
|
if (val !== Object(val)) {
|
|
2396
2495
|
throw new AssertionError(
|
|
@@ -2408,7 +2507,7 @@ Assertion.addProperty("empty", function() {
|
|
|
2408
2507
|
);
|
|
2409
2508
|
});
|
|
2410
2509
|
function checkArguments() {
|
|
2411
|
-
|
|
2510
|
+
let obj = flag2(this, "object"), type3 = type(obj);
|
|
2412
2511
|
this.assert(
|
|
2413
2512
|
"Arguments" === type3,
|
|
2414
2513
|
"expected #{this} to be arguments but got " + type3,
|
|
@@ -2421,9 +2520,9 @@ Assertion.addProperty("Arguments", checkArguments);
|
|
|
2421
2520
|
function assertEqual(val, msg) {
|
|
2422
2521
|
if (msg)
|
|
2423
2522
|
flag2(this, "message", msg);
|
|
2424
|
-
|
|
2523
|
+
let obj = flag2(this, "object");
|
|
2425
2524
|
if (flag2(this, "deep")) {
|
|
2426
|
-
|
|
2525
|
+
let prevLockSsfi = flag2(this, "lockSsfi");
|
|
2427
2526
|
flag2(this, "lockSsfi", true);
|
|
2428
2527
|
this.eql(val);
|
|
2429
2528
|
flag2(this, "lockSsfi", prevLockSsfi);
|
|
@@ -2445,7 +2544,7 @@ Assertion.addMethod("eq", assertEqual);
|
|
|
2445
2544
|
function assertEql(obj, msg) {
|
|
2446
2545
|
if (msg)
|
|
2447
2546
|
flag2(this, "message", msg);
|
|
2448
|
-
|
|
2547
|
+
let eql = flag2(this, "eql");
|
|
2449
2548
|
this.assert(
|
|
2450
2549
|
eql(obj, flag2(this, "object")),
|
|
2451
2550
|
"expected #{this} to deeply equal #{exp}",
|
|
@@ -2461,7 +2560,7 @@ Assertion.addMethod("eqls", assertEql);
|
|
|
2461
2560
|
function assertAbove(n, msg) {
|
|
2462
2561
|
if (msg)
|
|
2463
2562
|
flag2(this, "message", msg);
|
|
2464
|
-
|
|
2563
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
|
|
2465
2564
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2466
2565
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2467
2566
|
}
|
|
@@ -2478,7 +2577,7 @@ function assertAbove(n, msg) {
|
|
|
2478
2577
|
ssfi
|
|
2479
2578
|
);
|
|
2480
2579
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2481
|
-
|
|
2580
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2482
2581
|
throw new AssertionError(
|
|
2483
2582
|
msgPrefix + "expected " + printObj + " to be a number or a date",
|
|
2484
2583
|
void 0,
|
|
@@ -2486,7 +2585,7 @@ function assertAbove(n, msg) {
|
|
|
2486
2585
|
);
|
|
2487
2586
|
}
|
|
2488
2587
|
if (doLength) {
|
|
2489
|
-
|
|
2588
|
+
let descriptor = "length", itemsCount;
|
|
2490
2589
|
if (objType === "map" || objType === "set") {
|
|
2491
2590
|
descriptor = "size";
|
|
2492
2591
|
itemsCount = obj.size;
|
|
@@ -2516,7 +2615,7 @@ Assertion.addMethod("greaterThan", assertAbove);
|
|
|
2516
2615
|
function assertLeast(n, msg) {
|
|
2517
2616
|
if (msg)
|
|
2518
2617
|
flag2(this, "message", msg);
|
|
2519
|
-
|
|
2618
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2520
2619
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2521
2620
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2522
2621
|
}
|
|
@@ -2525,7 +2624,7 @@ function assertLeast(n, msg) {
|
|
|
2525
2624
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2526
2625
|
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2527
2626
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2528
|
-
|
|
2627
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2529
2628
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2530
2629
|
} else {
|
|
2531
2630
|
shouldThrow = false;
|
|
@@ -2534,7 +2633,7 @@ function assertLeast(n, msg) {
|
|
|
2534
2633
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2535
2634
|
}
|
|
2536
2635
|
if (doLength) {
|
|
2537
|
-
|
|
2636
|
+
let descriptor = "length", itemsCount;
|
|
2538
2637
|
if (objType === "map" || objType === "set") {
|
|
2539
2638
|
descriptor = "size";
|
|
2540
2639
|
itemsCount = obj.size;
|
|
@@ -2564,7 +2663,7 @@ Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
|
2564
2663
|
function assertBelow(n, msg) {
|
|
2565
2664
|
if (msg)
|
|
2566
2665
|
flag2(this, "message", msg);
|
|
2567
|
-
|
|
2666
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2568
2667
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2569
2668
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2570
2669
|
}
|
|
@@ -2573,7 +2672,7 @@ function assertBelow(n, msg) {
|
|
|
2573
2672
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2574
2673
|
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2575
2674
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2576
|
-
|
|
2675
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2577
2676
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2578
2677
|
} else {
|
|
2579
2678
|
shouldThrow = false;
|
|
@@ -2582,7 +2681,7 @@ function assertBelow(n, msg) {
|
|
|
2582
2681
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2583
2682
|
}
|
|
2584
2683
|
if (doLength) {
|
|
2585
|
-
|
|
2684
|
+
let descriptor = "length", itemsCount;
|
|
2586
2685
|
if (objType === "map" || objType === "set") {
|
|
2587
2686
|
descriptor = "size";
|
|
2588
2687
|
itemsCount = obj.size;
|
|
@@ -2612,7 +2711,7 @@ Assertion.addMethod("lessThan", assertBelow);
|
|
|
2612
2711
|
function assertMost(n, msg) {
|
|
2613
2712
|
if (msg)
|
|
2614
2713
|
flag2(this, "message", msg);
|
|
2615
|
-
|
|
2714
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2616
2715
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2617
2716
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2618
2717
|
}
|
|
@@ -2621,7 +2720,7 @@ function assertMost(n, msg) {
|
|
|
2621
2720
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2622
2721
|
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2623
2722
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2624
|
-
|
|
2723
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2625
2724
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2626
2725
|
} else {
|
|
2627
2726
|
shouldThrow = false;
|
|
@@ -2630,7 +2729,7 @@ function assertMost(n, msg) {
|
|
|
2630
2729
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2631
2730
|
}
|
|
2632
2731
|
if (doLength) {
|
|
2633
|
-
|
|
2732
|
+
let descriptor = "length", itemsCount;
|
|
2634
2733
|
if (objType === "map" || objType === "set") {
|
|
2635
2734
|
descriptor = "size";
|
|
2636
2735
|
itemsCount = obj.size;
|
|
@@ -2660,7 +2759,7 @@ Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
|
2660
2759
|
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2661
2760
|
if (msg)
|
|
2662
2761
|
flag2(this, "message", msg);
|
|
2663
|
-
|
|
2762
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
2664
2763
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2665
2764
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2666
2765
|
}
|
|
@@ -2669,7 +2768,7 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2669
2768
|
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2670
2769
|
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2671
2770
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2672
|
-
|
|
2771
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2673
2772
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2674
2773
|
} else {
|
|
2675
2774
|
shouldThrow = false;
|
|
@@ -2678,7 +2777,7 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2678
2777
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2679
2778
|
}
|
|
2680
2779
|
if (doLength) {
|
|
2681
|
-
|
|
2780
|
+
let descriptor = "length", itemsCount;
|
|
2682
2781
|
if (objType === "map" || objType === "set") {
|
|
2683
2782
|
descriptor = "size";
|
|
2684
2783
|
itemsCount = obj.size;
|
|
@@ -2701,11 +2800,12 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2701
2800
|
function assertInstanceOf(constructor, msg) {
|
|
2702
2801
|
if (msg)
|
|
2703
2802
|
flag2(this, "message", msg);
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2803
|
+
let target = flag2(this, "object");
|
|
2804
|
+
let ssfi = flag2(this, "ssfi");
|
|
2805
|
+
let flagMsg = flag2(this, "message");
|
|
2806
|
+
let isInstanceOf;
|
|
2707
2807
|
try {
|
|
2708
|
-
|
|
2808
|
+
isInstanceOf = target instanceof constructor;
|
|
2709
2809
|
} catch (err) {
|
|
2710
2810
|
if (err instanceof TypeError) {
|
|
2711
2811
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
@@ -2717,7 +2817,7 @@ function assertInstanceOf(constructor, msg) {
|
|
|
2717
2817
|
}
|
|
2718
2818
|
throw err;
|
|
2719
2819
|
}
|
|
2720
|
-
|
|
2820
|
+
let name = getName(constructor);
|
|
2721
2821
|
if (name == null) {
|
|
2722
2822
|
name = "an unnamed constructor";
|
|
2723
2823
|
}
|
|
@@ -2733,7 +2833,7 @@ Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
|
2733
2833
|
function assertProperty(name, val, msg) {
|
|
2734
2834
|
if (msg)
|
|
2735
2835
|
flag2(this, "message", msg);
|
|
2736
|
-
|
|
2836
|
+
let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2737
2837
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2738
2838
|
if (isNested) {
|
|
2739
2839
|
if (nameType !== "string") {
|
|
@@ -2766,8 +2866,8 @@ function assertProperty(name, val, msg) {
|
|
|
2766
2866
|
ssfi
|
|
2767
2867
|
);
|
|
2768
2868
|
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2869
|
+
let isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name], isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2870
|
+
let descriptor = "";
|
|
2771
2871
|
if (isDeep)
|
|
2772
2872
|
descriptor += "deep ";
|
|
2773
2873
|
if (isOwn)
|
|
@@ -2775,7 +2875,7 @@ function assertProperty(name, val, msg) {
|
|
|
2775
2875
|
if (isNested)
|
|
2776
2876
|
descriptor += "nested ";
|
|
2777
2877
|
descriptor += "property ";
|
|
2778
|
-
|
|
2878
|
+
let hasProperty2;
|
|
2779
2879
|
if (isOwn)
|
|
2780
2880
|
hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
|
|
2781
2881
|
else if (isNested)
|
|
@@ -2816,9 +2916,9 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
|
2816
2916
|
}
|
|
2817
2917
|
if (msg)
|
|
2818
2918
|
flag2(this, "message", msg);
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2919
|
+
let obj = flag2(this, "object");
|
|
2920
|
+
let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
2921
|
+
let eql = flag2(this, "eql");
|
|
2822
2922
|
if (actualDescriptor && descriptor) {
|
|
2823
2923
|
this.assert(
|
|
2824
2924
|
eql(descriptor, actualDescriptor),
|
|
@@ -2847,7 +2947,7 @@ __name(assertLengthChain, "assertLengthChain");
|
|
|
2847
2947
|
function assertLength(n, msg) {
|
|
2848
2948
|
if (msg)
|
|
2849
2949
|
flag2(this, "message", msg);
|
|
2850
|
-
|
|
2950
|
+
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
2851
2951
|
switch (objType) {
|
|
2852
2952
|
case "map":
|
|
2853
2953
|
case "set":
|
|
@@ -2872,7 +2972,7 @@ Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
|
2872
2972
|
function assertMatch(re, msg) {
|
|
2873
2973
|
if (msg)
|
|
2874
2974
|
flag2(this, "message", msg);
|
|
2875
|
-
|
|
2975
|
+
let obj = flag2(this, "object");
|
|
2876
2976
|
this.assert(
|
|
2877
2977
|
re.exec(obj),
|
|
2878
2978
|
"expected #{this} to match " + re,
|
|
@@ -2885,7 +2985,7 @@ Assertion.addMethod("matches", assertMatch);
|
|
|
2885
2985
|
Assertion.addMethod("string", function(str, msg) {
|
|
2886
2986
|
if (msg)
|
|
2887
2987
|
flag2(this, "message", msg);
|
|
2888
|
-
|
|
2988
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2889
2989
|
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
2890
2990
|
this.assert(
|
|
2891
2991
|
~obj.indexOf(str),
|
|
@@ -2894,9 +2994,9 @@ Assertion.addMethod("string", function(str, msg) {
|
|
|
2894
2994
|
);
|
|
2895
2995
|
});
|
|
2896
2996
|
function assertKeys(keys) {
|
|
2897
|
-
|
|
2997
|
+
let obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
|
|
2898
2998
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2899
|
-
|
|
2999
|
+
let mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
|
|
2900
3000
|
if (objType === "Map" || objType === "Set") {
|
|
2901
3001
|
deepStr = isDeep ? "deeply " : "";
|
|
2902
3002
|
actual = [];
|
|
@@ -2930,7 +3030,7 @@ function assertKeys(keys) {
|
|
|
2930
3030
|
if (!keys.length) {
|
|
2931
3031
|
throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
2932
3032
|
}
|
|
2933
|
-
|
|
3033
|
+
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2934
3034
|
if (!any && !all) {
|
|
2935
3035
|
all = true;
|
|
2936
3036
|
}
|
|
@@ -2955,7 +3055,7 @@ function assertKeys(keys) {
|
|
|
2955
3055
|
keys = keys.map(function(key) {
|
|
2956
3056
|
return inspect2(key);
|
|
2957
3057
|
});
|
|
2958
|
-
|
|
3058
|
+
let last = keys.pop();
|
|
2959
3059
|
if (all) {
|
|
2960
3060
|
str = keys.join(", ") + ", and " + last;
|
|
2961
3061
|
}
|
|
@@ -2982,7 +3082,7 @@ Assertion.addMethod("key", assertKeys);
|
|
|
2982
3082
|
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
2983
3083
|
if (msg)
|
|
2984
3084
|
flag2(this, "message", msg);
|
|
2985
|
-
|
|
3085
|
+
let obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
2986
3086
|
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
2987
3087
|
if (isRegExp2(errorLike) || typeof errorLike === "string") {
|
|
2988
3088
|
errMsgMatcher = errorLike;
|
|
@@ -2996,12 +3096,12 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2996
3096
|
errorWasThrown = true;
|
|
2997
3097
|
caughtErr = err;
|
|
2998
3098
|
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3099
|
+
let everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
|
|
3100
|
+
let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
3101
|
+
let errorLikeFail = false;
|
|
3102
|
+
let errMsgMatcherFail = false;
|
|
3003
3103
|
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
3004
|
-
|
|
3104
|
+
let errorLikeString = "an error";
|
|
3005
3105
|
if (errorLike instanceof Error) {
|
|
3006
3106
|
errorLikeString = "#{exp}";
|
|
3007
3107
|
} else if (errorLike) {
|
|
@@ -3028,7 +3128,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3028
3128
|
}
|
|
3029
3129
|
if (errorLike && caughtErr) {
|
|
3030
3130
|
if (errorLike instanceof Error) {
|
|
3031
|
-
|
|
3131
|
+
let isCompatibleInstance = check_error_exports.compatibleInstance(
|
|
3032
3132
|
caughtErr,
|
|
3033
3133
|
errorLike
|
|
3034
3134
|
);
|
|
@@ -3046,7 +3146,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3046
3146
|
}
|
|
3047
3147
|
}
|
|
3048
3148
|
}
|
|
3049
|
-
|
|
3149
|
+
let isCompatibleConstructor = check_error_exports.compatibleConstructor(
|
|
3050
3150
|
caughtErr,
|
|
3051
3151
|
errorLike
|
|
3052
3152
|
);
|
|
@@ -3065,11 +3165,11 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3065
3165
|
}
|
|
3066
3166
|
}
|
|
3067
3167
|
if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
|
|
3068
|
-
|
|
3168
|
+
let placeholder = "including";
|
|
3069
3169
|
if (isRegExp2(errMsgMatcher)) {
|
|
3070
3170
|
placeholder = "matching";
|
|
3071
3171
|
}
|
|
3072
|
-
|
|
3172
|
+
let isCompatibleMessage = check_error_exports.compatibleMessage(
|
|
3073
3173
|
caughtErr,
|
|
3074
3174
|
errMsgMatcher
|
|
3075
3175
|
);
|
|
@@ -3105,7 +3205,7 @@ Assertion.addMethod("Throw", assertThrows);
|
|
|
3105
3205
|
function respondTo(method, msg) {
|
|
3106
3206
|
if (msg)
|
|
3107
3207
|
flag2(this, "message", msg);
|
|
3108
|
-
|
|
3208
|
+
let obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
|
|
3109
3209
|
this.assert(
|
|
3110
3210
|
"function" === typeof context,
|
|
3111
3211
|
"expected #{this} to respond to " + inspect2(method),
|
|
@@ -3121,8 +3221,8 @@ Assertion.addProperty("itself", function() {
|
|
|
3121
3221
|
function satisfy(matcher, msg) {
|
|
3122
3222
|
if (msg)
|
|
3123
3223
|
flag2(this, "message", msg);
|
|
3124
|
-
|
|
3125
|
-
|
|
3224
|
+
let obj = flag2(this, "object");
|
|
3225
|
+
let result = matcher(obj);
|
|
3126
3226
|
this.assert(
|
|
3127
3227
|
result,
|
|
3128
3228
|
"expected #{this} to satisfy " + objDisplay(matcher),
|
|
@@ -3137,23 +3237,25 @@ Assertion.addMethod("satisfies", satisfy);
|
|
|
3137
3237
|
function closeTo(expected, delta, msg) {
|
|
3138
3238
|
if (msg)
|
|
3139
3239
|
flag2(this, "message", msg);
|
|
3140
|
-
|
|
3240
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3141
3241
|
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
3142
3242
|
let message = "A `delta` value is required for `closeTo`";
|
|
3143
|
-
if (delta == void 0)
|
|
3243
|
+
if (delta == void 0) {
|
|
3144
3244
|
throw new AssertionError(
|
|
3145
3245
|
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
3146
3246
|
void 0,
|
|
3147
3247
|
ssfi
|
|
3148
3248
|
);
|
|
3249
|
+
}
|
|
3149
3250
|
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
3150
3251
|
message = "A `expected` value is required for `closeTo`";
|
|
3151
|
-
if (expected == void 0)
|
|
3252
|
+
if (expected == void 0) {
|
|
3152
3253
|
throw new AssertionError(
|
|
3153
3254
|
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
3154
3255
|
void 0,
|
|
3155
3256
|
ssfi
|
|
3156
3257
|
);
|
|
3258
|
+
}
|
|
3157
3259
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
3158
3260
|
const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
|
|
3159
3261
|
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
@@ -3178,18 +3280,18 @@ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
|
|
|
3178
3280
|
if (ordered)
|
|
3179
3281
|
return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
3180
3282
|
if (!cmp) {
|
|
3181
|
-
|
|
3283
|
+
let matchIdx = superset.indexOf(elem);
|
|
3182
3284
|
if (matchIdx === -1)
|
|
3183
3285
|
return false;
|
|
3184
3286
|
if (!contains)
|
|
3185
3287
|
superset.splice(matchIdx, 1);
|
|
3186
3288
|
return true;
|
|
3187
3289
|
}
|
|
3188
|
-
return superset.some(function(elem2,
|
|
3290
|
+
return superset.some(function(elem2, matchIdx) {
|
|
3189
3291
|
if (!cmp(elem, elem2))
|
|
3190
3292
|
return false;
|
|
3191
3293
|
if (!contains)
|
|
3192
|
-
superset.splice(
|
|
3294
|
+
superset.splice(matchIdx, 1);
|
|
3193
3295
|
return true;
|
|
3194
3296
|
});
|
|
3195
3297
|
});
|
|
@@ -3198,12 +3300,12 @@ __name(isSubsetOf, "isSubsetOf");
|
|
|
3198
3300
|
Assertion.addMethod("members", function(subset, msg) {
|
|
3199
3301
|
if (msg)
|
|
3200
3302
|
flag2(this, "message", msg);
|
|
3201
|
-
|
|
3303
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3202
3304
|
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
|
|
3203
3305
|
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3306
|
+
let contains = flag2(this, "contains");
|
|
3307
|
+
let ordered = flag2(this, "ordered");
|
|
3308
|
+
let subject, failMsg, failNegateMsg;
|
|
3207
3309
|
if (contains) {
|
|
3208
3310
|
subject = ordered ? "an ordered superset" : "a superset";
|
|
3209
3311
|
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
@@ -3213,7 +3315,7 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
3213
3315
|
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
3214
3316
|
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
3215
3317
|
}
|
|
3216
|
-
|
|
3318
|
+
let cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
|
|
3217
3319
|
this.assert(
|
|
3218
3320
|
isSubsetOf(subset, obj, cmp, contains, ordered),
|
|
3219
3321
|
failMsg,
|
|
@@ -3226,7 +3328,7 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
3226
3328
|
Assertion.addProperty("iterable", function(msg) {
|
|
3227
3329
|
if (msg)
|
|
3228
3330
|
flag2(this, "message", msg);
|
|
3229
|
-
|
|
3331
|
+
let obj = flag2(this, "object");
|
|
3230
3332
|
this.assert(
|
|
3231
3333
|
obj != void 0 && obj[Symbol.iterator],
|
|
3232
3334
|
"expected #{this} to be an iterable",
|
|
@@ -3237,7 +3339,7 @@ Assertion.addProperty("iterable", function(msg) {
|
|
|
3237
3339
|
function oneOf(list, msg) {
|
|
3238
3340
|
if (msg)
|
|
3239
3341
|
flag2(this, "message", msg);
|
|
3240
|
-
|
|
3342
|
+
let expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
|
|
3241
3343
|
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
3242
3344
|
if (contains) {
|
|
3243
3345
|
this.assert(
|
|
@@ -3276,9 +3378,9 @@ Assertion.addMethod("oneOf", oneOf);
|
|
|
3276
3378
|
function assertChanges(subject, prop, msg) {
|
|
3277
3379
|
if (msg)
|
|
3278
3380
|
flag2(this, "message", msg);
|
|
3279
|
-
|
|
3381
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3280
3382
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3281
|
-
|
|
3383
|
+
let initial;
|
|
3282
3384
|
if (!prop) {
|
|
3283
3385
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3284
3386
|
initial = subject();
|
|
@@ -3287,8 +3389,8 @@ function assertChanges(subject, prop, msg) {
|
|
|
3287
3389
|
initial = subject[prop];
|
|
3288
3390
|
}
|
|
3289
3391
|
fn();
|
|
3290
|
-
|
|
3291
|
-
|
|
3392
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3393
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3292
3394
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3293
3395
|
flag2(this, "initialDeltaValue", initial);
|
|
3294
3396
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3306,9 +3408,9 @@ Assertion.addMethod("changes", assertChanges);
|
|
|
3306
3408
|
function assertIncreases(subject, prop, msg) {
|
|
3307
3409
|
if (msg)
|
|
3308
3410
|
flag2(this, "message", msg);
|
|
3309
|
-
|
|
3411
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3310
3412
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3311
|
-
|
|
3413
|
+
let initial;
|
|
3312
3414
|
if (!prop) {
|
|
3313
3415
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3314
3416
|
initial = subject();
|
|
@@ -3318,8 +3420,8 @@ function assertIncreases(subject, prop, msg) {
|
|
|
3318
3420
|
}
|
|
3319
3421
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3320
3422
|
fn();
|
|
3321
|
-
|
|
3322
|
-
|
|
3423
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3424
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3323
3425
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3324
3426
|
flag2(this, "initialDeltaValue", initial);
|
|
3325
3427
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3337,9 +3439,9 @@ Assertion.addMethod("increases", assertIncreases);
|
|
|
3337
3439
|
function assertDecreases(subject, prop, msg) {
|
|
3338
3440
|
if (msg)
|
|
3339
3441
|
flag2(this, "message", msg);
|
|
3340
|
-
|
|
3442
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3341
3443
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3342
|
-
|
|
3444
|
+
let initial;
|
|
3343
3445
|
if (!prop) {
|
|
3344
3446
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3345
3447
|
initial = subject();
|
|
@@ -3349,8 +3451,8 @@ function assertDecreases(subject, prop, msg) {
|
|
|
3349
3451
|
}
|
|
3350
3452
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3351
3453
|
fn();
|
|
3352
|
-
|
|
3353
|
-
|
|
3454
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3455
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3354
3456
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3355
3457
|
flag2(this, "initialDeltaValue", initial);
|
|
3356
3458
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3368,12 +3470,12 @@ Assertion.addMethod("decreases", assertDecreases);
|
|
|
3368
3470
|
function assertDelta(delta, msg) {
|
|
3369
3471
|
if (msg)
|
|
3370
3472
|
flag2(this, "message", msg);
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3473
|
+
let msgObj = flag2(this, "deltaMsgObj");
|
|
3474
|
+
let initial = flag2(this, "initialDeltaValue");
|
|
3475
|
+
let final = flag2(this, "finalDeltaValue");
|
|
3476
|
+
let behavior = flag2(this, "deltaBehavior");
|
|
3477
|
+
let realDelta = flag2(this, "realDelta");
|
|
3478
|
+
let expression;
|
|
3377
3479
|
if (behavior === "change") {
|
|
3378
3480
|
expression = Math.abs(final - initial) === Math.abs(delta);
|
|
3379
3481
|
} else {
|
|
@@ -3388,8 +3490,8 @@ function assertDelta(delta, msg) {
|
|
|
3388
3490
|
__name(assertDelta, "assertDelta");
|
|
3389
3491
|
Assertion.addMethod("by", assertDelta);
|
|
3390
3492
|
Assertion.addProperty("extensible", function() {
|
|
3391
|
-
|
|
3392
|
-
|
|
3493
|
+
let obj = flag2(this, "object");
|
|
3494
|
+
let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
3393
3495
|
this.assert(
|
|
3394
3496
|
isExtensible,
|
|
3395
3497
|
"expected #{this} to be extensible",
|
|
@@ -3397,8 +3499,8 @@ Assertion.addProperty("extensible", function() {
|
|
|
3397
3499
|
);
|
|
3398
3500
|
});
|
|
3399
3501
|
Assertion.addProperty("sealed", function() {
|
|
3400
|
-
|
|
3401
|
-
|
|
3502
|
+
let obj = flag2(this, "object");
|
|
3503
|
+
let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
3402
3504
|
this.assert(
|
|
3403
3505
|
isSealed,
|
|
3404
3506
|
"expected #{this} to be sealed",
|
|
@@ -3406,8 +3508,8 @@ Assertion.addProperty("sealed", function() {
|
|
|
3406
3508
|
);
|
|
3407
3509
|
});
|
|
3408
3510
|
Assertion.addProperty("frozen", function() {
|
|
3409
|
-
|
|
3410
|
-
|
|
3511
|
+
let obj = flag2(this, "object");
|
|
3512
|
+
let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
3411
3513
|
this.assert(
|
|
3412
3514
|
isFrozen,
|
|
3413
3515
|
"expected #{this} to be frozen",
|
|
@@ -3415,7 +3517,7 @@ Assertion.addProperty("frozen", function() {
|
|
|
3415
3517
|
);
|
|
3416
3518
|
});
|
|
3417
3519
|
Assertion.addProperty("finite", function(_msg) {
|
|
3418
|
-
|
|
3520
|
+
let obj = flag2(this, "object");
|
|
3419
3521
|
this.assert(
|
|
3420
3522
|
typeof obj === "number" && isFinite(obj),
|
|
3421
3523
|
"expected #{this} to be a finite number",
|
|
@@ -3453,8 +3555,8 @@ function compareSubset(expected, actual) {
|
|
|
3453
3555
|
}
|
|
3454
3556
|
}
|
|
3455
3557
|
return Object.keys(expected).every(function(key) {
|
|
3456
|
-
|
|
3457
|
-
|
|
3558
|
+
let expectedValue = expected[key];
|
|
3559
|
+
let actualValue = actual[key];
|
|
3458
3560
|
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
|
|
3459
3561
|
return compareSubset(expectedValue, actualValue);
|
|
3460
3562
|
}
|
|
@@ -3524,7 +3626,7 @@ function loadShould() {
|
|
|
3524
3626
|
get: shouldGetter,
|
|
3525
3627
|
configurable: true
|
|
3526
3628
|
});
|
|
3527
|
-
|
|
3629
|
+
let should2 = {};
|
|
3528
3630
|
should2.fail = function(actual, expected, message, operator) {
|
|
3529
3631
|
if (arguments.length < 2) {
|
|
3530
3632
|
message = actual;
|
|
@@ -3568,7 +3670,7 @@ __name(loadShould, "loadShould");
|
|
|
3568
3670
|
var should = loadShould;
|
|
3569
3671
|
var Should = loadShould;
|
|
3570
3672
|
function assert(express, errmsg) {
|
|
3571
|
-
|
|
3673
|
+
let test2 = new Assertion(null, null, assert, true);
|
|
3572
3674
|
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
3573
3675
|
}
|
|
3574
3676
|
__name(assert, "assert");
|
|
@@ -3595,7 +3697,7 @@ assert.isNotOk = function(val, msg) {
|
|
|
3595
3697
|
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
3596
3698
|
};
|
|
3597
3699
|
assert.equal = function(act, exp, msg) {
|
|
3598
|
-
|
|
3700
|
+
let test2 = new Assertion(act, msg, assert.equal, true);
|
|
3599
3701
|
test2.assert(
|
|
3600
3702
|
exp == flag(test2, "object"),
|
|
3601
3703
|
"expected #{this} to equal #{exp}",
|
|
@@ -3606,7 +3708,7 @@ assert.equal = function(act, exp, msg) {
|
|
|
3606
3708
|
);
|
|
3607
3709
|
};
|
|
3608
3710
|
assert.notEqual = function(act, exp, msg) {
|
|
3609
|
-
|
|
3711
|
+
let test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
3610
3712
|
test2.assert(
|
|
3611
3713
|
exp != flag(test2, "object"),
|
|
3612
3714
|
"expected #{this} to not equal #{exp}",
|
|
@@ -3963,7 +4065,7 @@ assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
|
3963
4065
|
errMsgMatcher = errorLike;
|
|
3964
4066
|
errorLike = null;
|
|
3965
4067
|
}
|
|
3966
|
-
|
|
4068
|
+
let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
3967
4069
|
errorLike,
|
|
3968
4070
|
errMsgMatcher
|
|
3969
4071
|
);
|
|
@@ -3980,7 +4082,7 @@ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
|
3980
4082
|
);
|
|
3981
4083
|
};
|
|
3982
4084
|
assert.operator = function(val, operator, val2, msg) {
|
|
3983
|
-
|
|
4085
|
+
let ok;
|
|
3984
4086
|
switch (operator) {
|
|
3985
4087
|
case "==":
|
|
3986
4088
|
ok = val == val2;
|
|
@@ -4014,7 +4116,7 @@ assert.operator = function(val, operator, val2, msg) {
|
|
|
4014
4116
|
assert.operator
|
|
4015
4117
|
);
|
|
4016
4118
|
}
|
|
4017
|
-
|
|
4119
|
+
let test2 = new Assertion(ok, msg, assert.operator, true);
|
|
4018
4120
|
test2.assert(
|
|
4019
4121
|
true === flag(test2, "object"),
|
|
4020
4122
|
"expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2),
|
|
@@ -4168,7 +4270,7 @@ assert.changes = function(fn, obj, prop, msg) {
|
|
|
4168
4270
|
};
|
|
4169
4271
|
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
4170
4272
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4171
|
-
|
|
4273
|
+
let tmpMsg = delta;
|
|
4172
4274
|
delta = prop;
|
|
4173
4275
|
msg = tmpMsg;
|
|
4174
4276
|
} else if (arguments.length === 3) {
|
|
@@ -4189,7 +4291,7 @@ assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
|
4189
4291
|
};
|
|
4190
4292
|
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
4191
4293
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4192
|
-
|
|
4294
|
+
let tmpMsg = delta;
|
|
4193
4295
|
delta = prop;
|
|
4194
4296
|
msg = tmpMsg;
|
|
4195
4297
|
} else if (arguments.length === 3) {
|
|
@@ -4207,7 +4309,7 @@ assert.increases = function(fn, obj, prop, msg) {
|
|
|
4207
4309
|
};
|
|
4208
4310
|
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
4209
4311
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4210
|
-
|
|
4312
|
+
let tmpMsg = delta;
|
|
4211
4313
|
delta = prop;
|
|
4212
4314
|
msg = tmpMsg;
|
|
4213
4315
|
} else if (arguments.length === 3) {
|
|
@@ -4228,7 +4330,7 @@ assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
|
4228
4330
|
};
|
|
4229
4331
|
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
4230
4332
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4231
|
-
|
|
4333
|
+
let tmpMsg = delta;
|
|
4232
4334
|
delta = prop;
|
|
4233
4335
|
msg = tmpMsg;
|
|
4234
4336
|
} else if (arguments.length === 3) {
|
|
@@ -4246,7 +4348,7 @@ assert.decreases = function(fn, obj, prop, msg) {
|
|
|
4246
4348
|
};
|
|
4247
4349
|
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
4248
4350
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4249
|
-
|
|
4351
|
+
let tmpMsg = delta;
|
|
4250
4352
|
delta = prop;
|
|
4251
4353
|
msg = tmpMsg;
|
|
4252
4354
|
} else if (arguments.length === 3) {
|
|
@@ -4267,7 +4369,7 @@ assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
|
4267
4369
|
};
|
|
4268
4370
|
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
4269
4371
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4270
|
-
|
|
4372
|
+
let tmpMsg = delta;
|
|
4271
4373
|
delta = prop;
|
|
4272
4374
|
msg = tmpMsg;
|
|
4273
4375
|
} else if (arguments.length === 3) {
|
|
@@ -4278,7 +4380,7 @@ assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
|
4278
4380
|
};
|
|
4279
4381
|
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
4280
4382
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4281
|
-
|
|
4383
|
+
let tmpMsg = delta;
|
|
4282
4384
|
delta = prop;
|
|
4283
4385
|
msg = tmpMsg;
|
|
4284
4386
|
} else if (arguments.length === 3) {
|