@rstest/core 0.4.1 → 0.5.1
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/LICENSE.md +127 -0
- package/dist/0~204.js +83 -0
- package/dist/0~223.js +19 -20
- package/dist/0~33.js +11 -23
- package/dist/0~655.js +3198 -8
- package/dist/0~655.js.LICENSE.txt +264 -0
- package/dist/0~691.js +58 -9
- package/dist/{0~938.js → 0~816.js} +183 -19
- package/dist/0~836.js +1 -1
- package/dist/0~85.js +20 -24
- package/dist/{0~669.js → 0~876.js} +36 -22
- package/dist/{0~120.js → 0~908.js} +333 -5
- package/dist/0~928.js +1 -1
- package/dist/0~969.js +1 -1
- package/dist/0~971.js +2 -2
- package/dist/index.js +594 -120
- package/dist/worker.js +651 -22
- package/dist-types/index.d.ts +250 -20
- package/dist-types/worker.d.ts +230 -18
- package/package.json +7 -5
package/dist/0~655.js
CHANGED
|
@@ -3389,7 +3389,7 @@ export const __webpack_modules__ = {
|
|
|
3389
3389
|
return serializeValue(new Error(`Failed to fully serialize error: ${null == e ? void 0 : e.message}\nInner error message: ${null == err ? void 0 : err.message}`));
|
|
3390
3390
|
}
|
|
3391
3391
|
}
|
|
3392
|
-
var
|
|
3392
|
+
var node_modules_chai = __webpack_require__("../../node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js");
|
|
3393
3393
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
3394
3394
|
const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
|
|
3395
3395
|
const GLOBAL_EXPECT = Symbol.for("expect-global");
|
|
@@ -4802,8 +4802,8 @@ ${printReceived(actual)}`
|
|
|
4802
4802
|
}
|
|
4803
4803
|
function getMatcherState(assertion, expect) {
|
|
4804
4804
|
const obj = assertion._obj;
|
|
4805
|
-
const isNot =
|
|
4806
|
-
const promise =
|
|
4805
|
+
const isNot = node_modules_chai.ZS.flag(assertion, "negate");
|
|
4806
|
+
const promise = node_modules_chai.ZS.flag(assertion, "promise") || "";
|
|
4807
4807
|
const jestUtils = {
|
|
4808
4808
|
...getMatcherUtils(),
|
|
4809
4809
|
diff: diff_diff,
|
|
@@ -4819,8 +4819,8 @@ ${printReceived(actual)}`
|
|
|
4819
4819
|
promise,
|
|
4820
4820
|
equals: dist_equals,
|
|
4821
4821
|
suppressedErrors: [],
|
|
4822
|
-
soft:
|
|
4823
|
-
poll:
|
|
4822
|
+
soft: node_modules_chai.ZS.flag(assertion, "soft"),
|
|
4823
|
+
poll: node_modules_chai.ZS.flag(assertion, "poll")
|
|
4824
4824
|
};
|
|
4825
4825
|
return {
|
|
4826
4826
|
state: matcherState,
|
|
@@ -4895,7 +4895,7 @@ ${printReceived(actual)}`
|
|
|
4895
4895
|
}
|
|
4896
4896
|
const JestExtend = (chai, utils)=>{
|
|
4897
4897
|
utils.addMethod(chai.expect, "extend", (expect, expects)=>{
|
|
4898
|
-
(0,
|
|
4898
|
+
(0, node_modules_chai.Yx)(JestExtendPlugin(chai, expect, expects));
|
|
4899
4899
|
});
|
|
4900
4900
|
};
|
|
4901
4901
|
},
|
|
@@ -6046,7 +6046,7 @@ ${printReceived(actual)}`
|
|
|
6046
6046
|
cN: ()=>stripSnapshotIndentation,
|
|
6047
6047
|
s: ()=>SnapshotClient
|
|
6048
6048
|
});
|
|
6049
|
-
var pathe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("pathe");
|
|
6049
|
+
var pathe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
|
|
6050
6050
|
var _vitest_pretty_format__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@vitest+pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js");
|
|
6051
6051
|
const comma = ','.charCodeAt(0);
|
|
6052
6052
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -6570,7 +6570,7 @@ ${printReceived(actual)}`
|
|
|
6570
6570
|
if (!file || !lineNumber || !columnNumber) return null;
|
|
6571
6571
|
if (method.startsWith("async ")) method = method.slice(6);
|
|
6572
6572
|
if (file.startsWith("file://")) file = file.slice(7);
|
|
6573
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : (0, pathe__WEBPACK_IMPORTED_MODULE_0__.
|
|
6573
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : (0, pathe__WEBPACK_IMPORTED_MODULE_0__.r)(file);
|
|
6574
6574
|
if (method) method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
6575
6575
|
return {
|
|
6576
6576
|
method,
|
|
@@ -7976,6 +7976,3196 @@ ${printReceived(actual)}`
|
|
|
7976
7976
|
}
|
|
7977
7977
|
}
|
|
7978
7978
|
},
|
|
7979
|
+
"../../node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
7980
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7981
|
+
E3: ()=>expect,
|
|
7982
|
+
Yx: ()=>use,
|
|
7983
|
+
ZS: ()=>utils_exports,
|
|
7984
|
+
vA: ()=>assert,
|
|
7985
|
+
zo: ()=>Assertion
|
|
7986
|
+
});
|
|
7987
|
+
var __defProp = Object.defineProperty;
|
|
7988
|
+
var __name = (target, value)=>__defProp(target, "name", {
|
|
7989
|
+
value,
|
|
7990
|
+
configurable: true
|
|
7991
|
+
});
|
|
7992
|
+
var __export = (target, all)=>{
|
|
7993
|
+
for(var name in all)__defProp(target, name, {
|
|
7994
|
+
get: all[name],
|
|
7995
|
+
enumerable: true
|
|
7996
|
+
});
|
|
7997
|
+
};
|
|
7998
|
+
var utils_exports = {};
|
|
7999
|
+
__export(utils_exports, {
|
|
8000
|
+
addChainableMethod: ()=>addChainableMethod,
|
|
8001
|
+
addLengthGuard: ()=>addLengthGuard,
|
|
8002
|
+
addMethod: ()=>addMethod,
|
|
8003
|
+
addProperty: ()=>addProperty,
|
|
8004
|
+
checkError: ()=>check_error_exports,
|
|
8005
|
+
compareByInspect: ()=>compareByInspect,
|
|
8006
|
+
eql: ()=>deep_eql_default,
|
|
8007
|
+
expectTypes: ()=>expectTypes,
|
|
8008
|
+
flag: ()=>flag,
|
|
8009
|
+
getActual: ()=>getActual,
|
|
8010
|
+
getMessage: ()=>getMessage2,
|
|
8011
|
+
getName: ()=>getName,
|
|
8012
|
+
getOperator: ()=>getOperator,
|
|
8013
|
+
getOwnEnumerableProperties: ()=>getOwnEnumerableProperties,
|
|
8014
|
+
getOwnEnumerablePropertySymbols: ()=>getOwnEnumerablePropertySymbols,
|
|
8015
|
+
getPathInfo: ()=>getPathInfo,
|
|
8016
|
+
hasProperty: ()=>hasProperty,
|
|
8017
|
+
inspect: ()=>inspect2,
|
|
8018
|
+
isNaN: ()=>isNaN2,
|
|
8019
|
+
isNumeric: ()=>isNumeric,
|
|
8020
|
+
isProxyEnabled: ()=>isProxyEnabled,
|
|
8021
|
+
isRegExp: ()=>isRegExp2,
|
|
8022
|
+
objDisplay: ()=>objDisplay,
|
|
8023
|
+
overwriteChainableMethod: ()=>overwriteChainableMethod,
|
|
8024
|
+
overwriteMethod: ()=>overwriteMethod,
|
|
8025
|
+
overwriteProperty: ()=>overwriteProperty,
|
|
8026
|
+
proxify: ()=>proxify,
|
|
8027
|
+
test: ()=>test,
|
|
8028
|
+
transferFlags: ()=>transferFlags,
|
|
8029
|
+
type: ()=>type
|
|
8030
|
+
});
|
|
8031
|
+
var check_error_exports = {};
|
|
8032
|
+
__export(check_error_exports, {
|
|
8033
|
+
compatibleConstructor: ()=>compatibleConstructor,
|
|
8034
|
+
compatibleInstance: ()=>compatibleInstance,
|
|
8035
|
+
compatibleMessage: ()=>compatibleMessage,
|
|
8036
|
+
getConstructorName: ()=>getConstructorName,
|
|
8037
|
+
getMessage: ()=>getMessage
|
|
8038
|
+
});
|
|
8039
|
+
function isErrorInstance(obj) {
|
|
8040
|
+
return obj instanceof Error || "[object Error]" === Object.prototype.toString.call(obj);
|
|
8041
|
+
}
|
|
8042
|
+
__name(isErrorInstance, "isErrorInstance");
|
|
8043
|
+
function isRegExp(obj) {
|
|
8044
|
+
return "[object RegExp]" === Object.prototype.toString.call(obj);
|
|
8045
|
+
}
|
|
8046
|
+
__name(isRegExp, "isRegExp");
|
|
8047
|
+
function compatibleInstance(thrown, errorLike) {
|
|
8048
|
+
return isErrorInstance(errorLike) && thrown === errorLike;
|
|
8049
|
+
}
|
|
8050
|
+
__name(compatibleInstance, "compatibleInstance");
|
|
8051
|
+
function compatibleConstructor(thrown, errorLike) {
|
|
8052
|
+
if (isErrorInstance(errorLike)) return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
8053
|
+
if (("object" == typeof errorLike || "function" == typeof errorLike) && errorLike.prototype) return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
8054
|
+
return false;
|
|
8055
|
+
}
|
|
8056
|
+
__name(compatibleConstructor, "compatibleConstructor");
|
|
8057
|
+
function compatibleMessage(thrown, errMatcher) {
|
|
8058
|
+
const comparisonString = "string" == typeof thrown ? thrown : thrown.message;
|
|
8059
|
+
if (isRegExp(errMatcher)) return errMatcher.test(comparisonString);
|
|
8060
|
+
if ("string" == typeof errMatcher) return -1 !== comparisonString.indexOf(errMatcher);
|
|
8061
|
+
return false;
|
|
8062
|
+
}
|
|
8063
|
+
__name(compatibleMessage, "compatibleMessage");
|
|
8064
|
+
function getConstructorName(errorLike) {
|
|
8065
|
+
let constructorName = errorLike;
|
|
8066
|
+
if (isErrorInstance(errorLike)) constructorName = errorLike.constructor.name;
|
|
8067
|
+
else if ("function" == typeof errorLike) {
|
|
8068
|
+
constructorName = errorLike.name;
|
|
8069
|
+
if ("" === constructorName) {
|
|
8070
|
+
const newConstructorName = new errorLike().name;
|
|
8071
|
+
constructorName = newConstructorName || constructorName;
|
|
8072
|
+
}
|
|
8073
|
+
}
|
|
8074
|
+
return constructorName;
|
|
8075
|
+
}
|
|
8076
|
+
__name(getConstructorName, "getConstructorName");
|
|
8077
|
+
function getMessage(errorLike) {
|
|
8078
|
+
let msg = "";
|
|
8079
|
+
if (errorLike && errorLike.message) msg = errorLike.message;
|
|
8080
|
+
else if ("string" == typeof errorLike) msg = errorLike;
|
|
8081
|
+
return msg;
|
|
8082
|
+
}
|
|
8083
|
+
__name(getMessage, "getMessage");
|
|
8084
|
+
function flag(obj, key, value) {
|
|
8085
|
+
let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
8086
|
+
if (3 !== arguments.length) return flags[key];
|
|
8087
|
+
flags[key] = value;
|
|
8088
|
+
}
|
|
8089
|
+
__name(flag, "flag");
|
|
8090
|
+
function test(obj, args) {
|
|
8091
|
+
let negate = flag(obj, "negate"), expr = args[0];
|
|
8092
|
+
return negate ? !expr : expr;
|
|
8093
|
+
}
|
|
8094
|
+
__name(test, "test");
|
|
8095
|
+
function type(obj) {
|
|
8096
|
+
if (void 0 === obj) return "undefined";
|
|
8097
|
+
if (null === obj) return "null";
|
|
8098
|
+
const stringTag = obj[Symbol.toStringTag];
|
|
8099
|
+
if ("string" == typeof stringTag) return stringTag;
|
|
8100
|
+
const type3 = Object.prototype.toString.call(obj).slice(8, -1);
|
|
8101
|
+
return type3;
|
|
8102
|
+
}
|
|
8103
|
+
__name(type, "type");
|
|
8104
|
+
var canElideFrames = "captureStackTrace" in Error;
|
|
8105
|
+
var AssertionError = class _AssertionError extends Error {
|
|
8106
|
+
static{
|
|
8107
|
+
__name(this, "AssertionError");
|
|
8108
|
+
}
|
|
8109
|
+
message;
|
|
8110
|
+
get name() {
|
|
8111
|
+
return "AssertionError";
|
|
8112
|
+
}
|
|
8113
|
+
get ok() {
|
|
8114
|
+
return false;
|
|
8115
|
+
}
|
|
8116
|
+
constructor(message = "Unspecified AssertionError", props, ssf){
|
|
8117
|
+
super(message);
|
|
8118
|
+
this.message = message;
|
|
8119
|
+
if (canElideFrames) Error.captureStackTrace(this, ssf || _AssertionError);
|
|
8120
|
+
for(const key in props)if (!(key in this)) this[key] = props[key];
|
|
8121
|
+
}
|
|
8122
|
+
toJSON(stack) {
|
|
8123
|
+
return {
|
|
8124
|
+
...this,
|
|
8125
|
+
name: this.name,
|
|
8126
|
+
message: this.message,
|
|
8127
|
+
ok: false,
|
|
8128
|
+
stack: false !== stack ? this.stack : void 0
|
|
8129
|
+
};
|
|
8130
|
+
}
|
|
8131
|
+
};
|
|
8132
|
+
function expectTypes(obj, types) {
|
|
8133
|
+
let flagMsg = flag(obj, "message");
|
|
8134
|
+
let ssfi = flag(obj, "ssfi");
|
|
8135
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
8136
|
+
obj = flag(obj, "object");
|
|
8137
|
+
types = types.map(function(t) {
|
|
8138
|
+
return t.toLowerCase();
|
|
8139
|
+
});
|
|
8140
|
+
types.sort();
|
|
8141
|
+
let str = types.map(function(t, index) {
|
|
8142
|
+
let art = ~[
|
|
8143
|
+
"a",
|
|
8144
|
+
"e",
|
|
8145
|
+
"i",
|
|
8146
|
+
"o",
|
|
8147
|
+
"u"
|
|
8148
|
+
].indexOf(t.charAt(0)) ? "an" : "a";
|
|
8149
|
+
let or = types.length > 1 && index === types.length - 1 ? "or " : "";
|
|
8150
|
+
return or + art + " " + t;
|
|
8151
|
+
}).join(", ");
|
|
8152
|
+
let objType = type(obj).toLowerCase();
|
|
8153
|
+
if (!types.some(function(expected) {
|
|
8154
|
+
return objType === expected;
|
|
8155
|
+
})) throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi);
|
|
8156
|
+
}
|
|
8157
|
+
__name(expectTypes, "expectTypes");
|
|
8158
|
+
function getActual(obj, args) {
|
|
8159
|
+
return args.length > 4 ? args[4] : obj._obj;
|
|
8160
|
+
}
|
|
8161
|
+
__name(getActual, "getActual");
|
|
8162
|
+
var ansiColors = {
|
|
8163
|
+
bold: [
|
|
8164
|
+
"1",
|
|
8165
|
+
"22"
|
|
8166
|
+
],
|
|
8167
|
+
dim: [
|
|
8168
|
+
"2",
|
|
8169
|
+
"22"
|
|
8170
|
+
],
|
|
8171
|
+
italic: [
|
|
8172
|
+
"3",
|
|
8173
|
+
"23"
|
|
8174
|
+
],
|
|
8175
|
+
underline: [
|
|
8176
|
+
"4",
|
|
8177
|
+
"24"
|
|
8178
|
+
],
|
|
8179
|
+
inverse: [
|
|
8180
|
+
"7",
|
|
8181
|
+
"27"
|
|
8182
|
+
],
|
|
8183
|
+
hidden: [
|
|
8184
|
+
"8",
|
|
8185
|
+
"28"
|
|
8186
|
+
],
|
|
8187
|
+
strike: [
|
|
8188
|
+
"9",
|
|
8189
|
+
"29"
|
|
8190
|
+
],
|
|
8191
|
+
black: [
|
|
8192
|
+
"30",
|
|
8193
|
+
"39"
|
|
8194
|
+
],
|
|
8195
|
+
red: [
|
|
8196
|
+
"31",
|
|
8197
|
+
"39"
|
|
8198
|
+
],
|
|
8199
|
+
green: [
|
|
8200
|
+
"32",
|
|
8201
|
+
"39"
|
|
8202
|
+
],
|
|
8203
|
+
yellow: [
|
|
8204
|
+
"33",
|
|
8205
|
+
"39"
|
|
8206
|
+
],
|
|
8207
|
+
blue: [
|
|
8208
|
+
"34",
|
|
8209
|
+
"39"
|
|
8210
|
+
],
|
|
8211
|
+
magenta: [
|
|
8212
|
+
"35",
|
|
8213
|
+
"39"
|
|
8214
|
+
],
|
|
8215
|
+
cyan: [
|
|
8216
|
+
"36",
|
|
8217
|
+
"39"
|
|
8218
|
+
],
|
|
8219
|
+
white: [
|
|
8220
|
+
"37",
|
|
8221
|
+
"39"
|
|
8222
|
+
],
|
|
8223
|
+
brightblack: [
|
|
8224
|
+
"30;1",
|
|
8225
|
+
"39"
|
|
8226
|
+
],
|
|
8227
|
+
brightred: [
|
|
8228
|
+
"31;1",
|
|
8229
|
+
"39"
|
|
8230
|
+
],
|
|
8231
|
+
brightgreen: [
|
|
8232
|
+
"32;1",
|
|
8233
|
+
"39"
|
|
8234
|
+
],
|
|
8235
|
+
brightyellow: [
|
|
8236
|
+
"33;1",
|
|
8237
|
+
"39"
|
|
8238
|
+
],
|
|
8239
|
+
brightblue: [
|
|
8240
|
+
"34;1",
|
|
8241
|
+
"39"
|
|
8242
|
+
],
|
|
8243
|
+
brightmagenta: [
|
|
8244
|
+
"35;1",
|
|
8245
|
+
"39"
|
|
8246
|
+
],
|
|
8247
|
+
brightcyan: [
|
|
8248
|
+
"36;1",
|
|
8249
|
+
"39"
|
|
8250
|
+
],
|
|
8251
|
+
brightwhite: [
|
|
8252
|
+
"37;1",
|
|
8253
|
+
"39"
|
|
8254
|
+
],
|
|
8255
|
+
grey: [
|
|
8256
|
+
"90",
|
|
8257
|
+
"39"
|
|
8258
|
+
]
|
|
8259
|
+
};
|
|
8260
|
+
var styles = {
|
|
8261
|
+
special: "cyan",
|
|
8262
|
+
number: "yellow",
|
|
8263
|
+
bigint: "yellow",
|
|
8264
|
+
boolean: "yellow",
|
|
8265
|
+
undefined: "grey",
|
|
8266
|
+
null: "bold",
|
|
8267
|
+
string: "green",
|
|
8268
|
+
symbol: "green",
|
|
8269
|
+
date: "magenta",
|
|
8270
|
+
regexp: "red"
|
|
8271
|
+
};
|
|
8272
|
+
var truncator = "\u2026";
|
|
8273
|
+
function colorise(value, styleType) {
|
|
8274
|
+
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
|
8275
|
+
if (!color) return String(value);
|
|
8276
|
+
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
|
8277
|
+
}
|
|
8278
|
+
__name(colorise, "colorise");
|
|
8279
|
+
function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = 1 / 0, breakLength = 1 / 0, seen = [], truncate: truncate2 = 1 / 0, stylize = String } = {}, inspect3) {
|
|
8280
|
+
const options = {
|
|
8281
|
+
showHidden: Boolean(showHidden),
|
|
8282
|
+
depth: Number(depth),
|
|
8283
|
+
colors: Boolean(colors),
|
|
8284
|
+
customInspect: Boolean(customInspect),
|
|
8285
|
+
showProxy: Boolean(showProxy),
|
|
8286
|
+
maxArrayLength: Number(maxArrayLength),
|
|
8287
|
+
breakLength: Number(breakLength),
|
|
8288
|
+
truncate: Number(truncate2),
|
|
8289
|
+
seen,
|
|
8290
|
+
inspect: inspect3,
|
|
8291
|
+
stylize
|
|
8292
|
+
};
|
|
8293
|
+
if (options.colors) options.stylize = colorise;
|
|
8294
|
+
return options;
|
|
8295
|
+
}
|
|
8296
|
+
__name(normaliseOptions, "normaliseOptions");
|
|
8297
|
+
function isHighSurrogate(char) {
|
|
8298
|
+
return char >= "\uD800" && char <= "\uDBFF";
|
|
8299
|
+
}
|
|
8300
|
+
__name(isHighSurrogate, "isHighSurrogate");
|
|
8301
|
+
function truncate(string, length, tail = truncator) {
|
|
8302
|
+
string = String(string);
|
|
8303
|
+
const tailLength = tail.length;
|
|
8304
|
+
const stringLength = string.length;
|
|
8305
|
+
if (tailLength > length && stringLength > tailLength) return tail;
|
|
8306
|
+
if (stringLength > length && stringLength > tailLength) {
|
|
8307
|
+
let end = length - tailLength;
|
|
8308
|
+
if (end > 0 && isHighSurrogate(string[end - 1])) end -= 1;
|
|
8309
|
+
return `${string.slice(0, end)}${tail}`;
|
|
8310
|
+
}
|
|
8311
|
+
return string;
|
|
8312
|
+
}
|
|
8313
|
+
__name(truncate, "truncate");
|
|
8314
|
+
function inspectList(list, options, inspectItem, separator = ", ") {
|
|
8315
|
+
inspectItem = inspectItem || options.inspect;
|
|
8316
|
+
const size = list.length;
|
|
8317
|
+
if (0 === size) return "";
|
|
8318
|
+
const originalLength = options.truncate;
|
|
8319
|
+
let output = "";
|
|
8320
|
+
let peek = "";
|
|
8321
|
+
let truncated = "";
|
|
8322
|
+
for(let i = 0; i < size; i += 1){
|
|
8323
|
+
const last = i + 1 === list.length;
|
|
8324
|
+
const secondToLast = i + 2 === list.length;
|
|
8325
|
+
truncated = `${truncator}(${list.length - i})`;
|
|
8326
|
+
const value = list[i];
|
|
8327
|
+
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
8328
|
+
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
8329
|
+
const nextLength = output.length + string.length;
|
|
8330
|
+
const truncatedLength = nextLength + truncated.length;
|
|
8331
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
|
|
8332
|
+
if (!last && !secondToLast && truncatedLength > originalLength) break;
|
|
8333
|
+
peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
|
|
8334
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
|
|
8335
|
+
output += string;
|
|
8336
|
+
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
8337
|
+
truncated = `${truncator}(${list.length - i - 1})`;
|
|
8338
|
+
break;
|
|
8339
|
+
}
|
|
8340
|
+
truncated = "";
|
|
8341
|
+
}
|
|
8342
|
+
return `${output}${truncated}`;
|
|
8343
|
+
}
|
|
8344
|
+
__name(inspectList, "inspectList");
|
|
8345
|
+
function quoteComplexKey(key) {
|
|
8346
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
|
|
8347
|
+
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
8348
|
+
}
|
|
8349
|
+
__name(quoteComplexKey, "quoteComplexKey");
|
|
8350
|
+
function inspectProperty([key, value], options) {
|
|
8351
|
+
options.truncate -= 2;
|
|
8352
|
+
if ("string" == typeof key) key = quoteComplexKey(key);
|
|
8353
|
+
else if ("number" != typeof key) key = `[${options.inspect(key, options)}]`;
|
|
8354
|
+
options.truncate -= key.length;
|
|
8355
|
+
value = options.inspect(value, options);
|
|
8356
|
+
return `${key}: ${value}`;
|
|
8357
|
+
}
|
|
8358
|
+
__name(inspectProperty, "inspectProperty");
|
|
8359
|
+
function inspectArray(array, options) {
|
|
8360
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
8361
|
+
if (!array.length && !nonIndexProperties.length) return "[]";
|
|
8362
|
+
options.truncate -= 4;
|
|
8363
|
+
const listContents = inspectList(array, options);
|
|
8364
|
+
options.truncate -= listContents.length;
|
|
8365
|
+
let propertyContents = "";
|
|
8366
|
+
if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key)=>[
|
|
8367
|
+
key,
|
|
8368
|
+
array[key]
|
|
8369
|
+
]), options, inspectProperty);
|
|
8370
|
+
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
8371
|
+
}
|
|
8372
|
+
__name(inspectArray, "inspectArray");
|
|
8373
|
+
var getArrayName = /* @__PURE__ */ __name((array)=>{
|
|
8374
|
+
if ("function" == typeof Buffer && array instanceof Buffer) return "Buffer";
|
|
8375
|
+
if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
|
|
8376
|
+
return array.constructor.name;
|
|
8377
|
+
}, "getArrayName");
|
|
8378
|
+
function inspectTypedArray(array, options) {
|
|
8379
|
+
const name = getArrayName(array);
|
|
8380
|
+
options.truncate -= name.length + 4;
|
|
8381
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
8382
|
+
if (!array.length && !nonIndexProperties.length) return `${name}[]`;
|
|
8383
|
+
let output = "";
|
|
8384
|
+
for(let i = 0; i < array.length; i++){
|
|
8385
|
+
const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
|
|
8386
|
+
options.truncate -= string.length;
|
|
8387
|
+
if (array[i] !== array.length && options.truncate <= 3) {
|
|
8388
|
+
output += `${truncator}(${array.length - array[i] + 1})`;
|
|
8389
|
+
break;
|
|
8390
|
+
}
|
|
8391
|
+
output += string;
|
|
8392
|
+
}
|
|
8393
|
+
let propertyContents = "";
|
|
8394
|
+
if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key)=>[
|
|
8395
|
+
key,
|
|
8396
|
+
array[key]
|
|
8397
|
+
]), options, inspectProperty);
|
|
8398
|
+
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
8399
|
+
}
|
|
8400
|
+
__name(inspectTypedArray, "inspectTypedArray");
|
|
8401
|
+
function inspectDate(dateObject, options) {
|
|
8402
|
+
const stringRepresentation = dateObject.toJSON();
|
|
8403
|
+
if (null === stringRepresentation) return "Invalid Date";
|
|
8404
|
+
const split = stringRepresentation.split("T");
|
|
8405
|
+
const date = split[0];
|
|
8406
|
+
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
|
8407
|
+
}
|
|
8408
|
+
__name(inspectDate, "inspectDate");
|
|
8409
|
+
function inspectFunction(func, options) {
|
|
8410
|
+
const functionType = func[Symbol.toStringTag] || "Function";
|
|
8411
|
+
const name = func.name;
|
|
8412
|
+
if (!name) return options.stylize(`[${functionType}]`, "special");
|
|
8413
|
+
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
|
8414
|
+
}
|
|
8415
|
+
__name(inspectFunction, "inspectFunction");
|
|
8416
|
+
function inspectMapEntry([key, value], options) {
|
|
8417
|
+
options.truncate -= 4;
|
|
8418
|
+
key = options.inspect(key, options);
|
|
8419
|
+
options.truncate -= key.length;
|
|
8420
|
+
value = options.inspect(value, options);
|
|
8421
|
+
return `${key} => ${value}`;
|
|
8422
|
+
}
|
|
8423
|
+
__name(inspectMapEntry, "inspectMapEntry");
|
|
8424
|
+
function mapToEntries(map) {
|
|
8425
|
+
const entries = [];
|
|
8426
|
+
map.forEach((value, key)=>{
|
|
8427
|
+
entries.push([
|
|
8428
|
+
key,
|
|
8429
|
+
value
|
|
8430
|
+
]);
|
|
8431
|
+
});
|
|
8432
|
+
return entries;
|
|
8433
|
+
}
|
|
8434
|
+
__name(mapToEntries, "mapToEntries");
|
|
8435
|
+
function inspectMap(map, options) {
|
|
8436
|
+
if (0 === map.size) return "Map{}";
|
|
8437
|
+
options.truncate -= 7;
|
|
8438
|
+
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
8439
|
+
}
|
|
8440
|
+
__name(inspectMap, "inspectMap");
|
|
8441
|
+
var isNaN = Number.isNaN || ((i)=>i !== i);
|
|
8442
|
+
function inspectNumber(number, options) {
|
|
8443
|
+
if (isNaN(number)) return options.stylize("NaN", "number");
|
|
8444
|
+
if (number === 1 / 0) return options.stylize("Infinity", "number");
|
|
8445
|
+
if (number === -1 / 0) return options.stylize("-Infinity", "number");
|
|
8446
|
+
if (0 === number) return options.stylize(1 / number === 1 / 0 ? "+0" : "-0", "number");
|
|
8447
|
+
return options.stylize(truncate(String(number), options.truncate), "number");
|
|
8448
|
+
}
|
|
8449
|
+
__name(inspectNumber, "inspectNumber");
|
|
8450
|
+
function inspectBigInt(number, options) {
|
|
8451
|
+
let nums = truncate(number.toString(), options.truncate - 1);
|
|
8452
|
+
if (nums !== truncator) nums += "n";
|
|
8453
|
+
return options.stylize(nums, "bigint");
|
|
8454
|
+
}
|
|
8455
|
+
__name(inspectBigInt, "inspectBigInt");
|
|
8456
|
+
function inspectRegExp(value, options) {
|
|
8457
|
+
const flags = value.toString().split("/")[2];
|
|
8458
|
+
const sourceLength = options.truncate - (2 + flags.length);
|
|
8459
|
+
const source = value.source;
|
|
8460
|
+
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
|
|
8461
|
+
}
|
|
8462
|
+
__name(inspectRegExp, "inspectRegExp");
|
|
8463
|
+
function arrayFromSet(set2) {
|
|
8464
|
+
const values = [];
|
|
8465
|
+
set2.forEach((value)=>{
|
|
8466
|
+
values.push(value);
|
|
8467
|
+
});
|
|
8468
|
+
return values;
|
|
8469
|
+
}
|
|
8470
|
+
__name(arrayFromSet, "arrayFromSet");
|
|
8471
|
+
function inspectSet(set2, options) {
|
|
8472
|
+
if (0 === set2.size) return "Set{}";
|
|
8473
|
+
options.truncate -= 7;
|
|
8474
|
+
return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
|
|
8475
|
+
}
|
|
8476
|
+
__name(inspectSet, "inspectSet");
|
|
8477
|
+
var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
8478
|
+
var escapeCharacters = {
|
|
8479
|
+
"\b": "\\b",
|
|
8480
|
+
" ": "\\t",
|
|
8481
|
+
"\n": "\\n",
|
|
8482
|
+
"\f": "\\f",
|
|
8483
|
+
"\r": "\\r",
|
|
8484
|
+
"'": "\\'",
|
|
8485
|
+
"\\": "\\\\"
|
|
8486
|
+
};
|
|
8487
|
+
var hex = 16;
|
|
8488
|
+
var unicodeLength = 4;
|
|
8489
|
+
function escape(char) {
|
|
8490
|
+
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
|
|
8491
|
+
}
|
|
8492
|
+
__name(escape, "escape");
|
|
8493
|
+
function inspectString(string, options) {
|
|
8494
|
+
if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
|
|
8495
|
+
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
|
8496
|
+
}
|
|
8497
|
+
__name(inspectString, "inspectString");
|
|
8498
|
+
function inspectSymbol(value) {
|
|
8499
|
+
if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
8500
|
+
return value.toString();
|
|
8501
|
+
}
|
|
8502
|
+
__name(inspectSymbol, "inspectSymbol");
|
|
8503
|
+
var getPromiseValue = /* @__PURE__ */ __name(()=>"Promise{\u2026}", "getPromiseValue");
|
|
8504
|
+
var promise_default = getPromiseValue;
|
|
8505
|
+
function inspectObject(object, options) {
|
|
8506
|
+
const properties = Object.getOwnPropertyNames(object);
|
|
8507
|
+
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
8508
|
+
if (0 === properties.length && 0 === symbols.length) return "{}";
|
|
8509
|
+
options.truncate -= 4;
|
|
8510
|
+
options.seen = options.seen || [];
|
|
8511
|
+
if (options.seen.includes(object)) return "[Circular]";
|
|
8512
|
+
options.seen.push(object);
|
|
8513
|
+
const propertyContents = inspectList(properties.map((key)=>[
|
|
8514
|
+
key,
|
|
8515
|
+
object[key]
|
|
8516
|
+
]), options, inspectProperty);
|
|
8517
|
+
const symbolContents = inspectList(symbols.map((key)=>[
|
|
8518
|
+
key,
|
|
8519
|
+
object[key]
|
|
8520
|
+
]), options, inspectProperty);
|
|
8521
|
+
options.seen.pop();
|
|
8522
|
+
let sep = "";
|
|
8523
|
+
if (propertyContents && symbolContents) sep = ", ";
|
|
8524
|
+
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
8525
|
+
}
|
|
8526
|
+
__name(inspectObject, "inspectObject");
|
|
8527
|
+
var toStringTag = "undefined" != typeof Symbol && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
8528
|
+
function inspectClass(value, options) {
|
|
8529
|
+
let name = "";
|
|
8530
|
+
if (toStringTag && toStringTag in value) name = value[toStringTag];
|
|
8531
|
+
name = name || value.constructor.name;
|
|
8532
|
+
if (!name || "_class" === name) name = "<Anonymous Class>";
|
|
8533
|
+
options.truncate -= name.length;
|
|
8534
|
+
return `${name}${inspectObject(value, options)}`;
|
|
8535
|
+
}
|
|
8536
|
+
__name(inspectClass, "inspectClass");
|
|
8537
|
+
function inspectArguments(args, options) {
|
|
8538
|
+
if (0 === args.length) return "Arguments[]";
|
|
8539
|
+
options.truncate -= 13;
|
|
8540
|
+
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
8541
|
+
}
|
|
8542
|
+
__name(inspectArguments, "inspectArguments");
|
|
8543
|
+
var errorKeys = [
|
|
8544
|
+
"stack",
|
|
8545
|
+
"line",
|
|
8546
|
+
"column",
|
|
8547
|
+
"name",
|
|
8548
|
+
"message",
|
|
8549
|
+
"fileName",
|
|
8550
|
+
"lineNumber",
|
|
8551
|
+
"columnNumber",
|
|
8552
|
+
"number",
|
|
8553
|
+
"description",
|
|
8554
|
+
"cause"
|
|
8555
|
+
];
|
|
8556
|
+
function inspectObject2(error, options) {
|
|
8557
|
+
const properties = Object.getOwnPropertyNames(error).filter((key)=>-1 === errorKeys.indexOf(key));
|
|
8558
|
+
const name = error.name;
|
|
8559
|
+
options.truncate -= name.length;
|
|
8560
|
+
let message = "";
|
|
8561
|
+
if ("string" == typeof error.message) message = truncate(error.message, options.truncate);
|
|
8562
|
+
else properties.unshift("message");
|
|
8563
|
+
message = message ? `: ${message}` : "";
|
|
8564
|
+
options.truncate -= message.length + 5;
|
|
8565
|
+
options.seen = options.seen || [];
|
|
8566
|
+
if (options.seen.includes(error)) return "[Circular]";
|
|
8567
|
+
options.seen.push(error);
|
|
8568
|
+
const propertyContents = inspectList(properties.map((key)=>[
|
|
8569
|
+
key,
|
|
8570
|
+
error[key]
|
|
8571
|
+
]), options, inspectProperty);
|
|
8572
|
+
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
|
8573
|
+
}
|
|
8574
|
+
__name(inspectObject2, "inspectObject");
|
|
8575
|
+
function inspectAttribute([key, value], options) {
|
|
8576
|
+
options.truncate -= 3;
|
|
8577
|
+
if (!value) return `${options.stylize(String(key), "yellow")}`;
|
|
8578
|
+
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
8579
|
+
}
|
|
8580
|
+
__name(inspectAttribute, "inspectAttribute");
|
|
8581
|
+
function inspectNodeCollection(collection, options) {
|
|
8582
|
+
return inspectList(collection, options, inspectNode, "\n");
|
|
8583
|
+
}
|
|
8584
|
+
__name(inspectNodeCollection, "inspectNodeCollection");
|
|
8585
|
+
function inspectNode(node, options) {
|
|
8586
|
+
switch(node.nodeType){
|
|
8587
|
+
case 1:
|
|
8588
|
+
return inspectHTML(node, options);
|
|
8589
|
+
case 3:
|
|
8590
|
+
return options.inspect(node.data, options);
|
|
8591
|
+
default:
|
|
8592
|
+
return options.inspect(node, options);
|
|
8593
|
+
}
|
|
8594
|
+
}
|
|
8595
|
+
__name(inspectNode, "inspectNode");
|
|
8596
|
+
function inspectHTML(element, options) {
|
|
8597
|
+
const properties = element.getAttributeNames();
|
|
8598
|
+
const name = element.tagName.toLowerCase();
|
|
8599
|
+
const head = options.stylize(`<${name}`, "special");
|
|
8600
|
+
const headClose = options.stylize(">", "special");
|
|
8601
|
+
const tail = options.stylize(`</${name}>`, "special");
|
|
8602
|
+
options.truncate -= 2 * name.length + 5;
|
|
8603
|
+
let propertyContents = "";
|
|
8604
|
+
if (properties.length > 0) {
|
|
8605
|
+
propertyContents += " ";
|
|
8606
|
+
propertyContents += inspectList(properties.map((key)=>[
|
|
8607
|
+
key,
|
|
8608
|
+
element.getAttribute(key)
|
|
8609
|
+
]), options, inspectAttribute, " ");
|
|
8610
|
+
}
|
|
8611
|
+
options.truncate -= propertyContents.length;
|
|
8612
|
+
const truncate2 = options.truncate;
|
|
8613
|
+
let children = inspectNodeCollection(element.children, options);
|
|
8614
|
+
if (children && children.length > truncate2) children = `${truncator}(${element.children.length})`;
|
|
8615
|
+
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
8616
|
+
}
|
|
8617
|
+
__name(inspectHTML, "inspectHTML");
|
|
8618
|
+
var symbolsSupported = "function" == typeof Symbol && "function" == typeof Symbol.for;
|
|
8619
|
+
var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
8620
|
+
var nodeInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
8621
|
+
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
8622
|
+
var stringTagMap = {};
|
|
8623
|
+
var baseTypesMap = {
|
|
8624
|
+
undefined: /* @__PURE__ */ __name((value, options)=>options.stylize("undefined", "undefined"), "undefined"),
|
|
8625
|
+
null: /* @__PURE__ */ __name((value, options)=>options.stylize("null", "null"), "null"),
|
|
8626
|
+
boolean: /* @__PURE__ */ __name((value, options)=>options.stylize(String(value), "boolean"), "boolean"),
|
|
8627
|
+
Boolean: /* @__PURE__ */ __name((value, options)=>options.stylize(String(value), "boolean"), "Boolean"),
|
|
8628
|
+
number: inspectNumber,
|
|
8629
|
+
Number: inspectNumber,
|
|
8630
|
+
bigint: inspectBigInt,
|
|
8631
|
+
BigInt: inspectBigInt,
|
|
8632
|
+
string: inspectString,
|
|
8633
|
+
String: inspectString,
|
|
8634
|
+
function: inspectFunction,
|
|
8635
|
+
Function: inspectFunction,
|
|
8636
|
+
symbol: inspectSymbol,
|
|
8637
|
+
Symbol: inspectSymbol,
|
|
8638
|
+
Array: inspectArray,
|
|
8639
|
+
Date: inspectDate,
|
|
8640
|
+
Map: inspectMap,
|
|
8641
|
+
Set: inspectSet,
|
|
8642
|
+
RegExp: inspectRegExp,
|
|
8643
|
+
Promise: promise_default,
|
|
8644
|
+
WeakSet: /* @__PURE__ */ __name((value, options)=>options.stylize("WeakSet{\u2026}", "special"), "WeakSet"),
|
|
8645
|
+
WeakMap: /* @__PURE__ */ __name((value, options)=>options.stylize("WeakMap{\u2026}", "special"), "WeakMap"),
|
|
8646
|
+
Arguments: inspectArguments,
|
|
8647
|
+
Int8Array: inspectTypedArray,
|
|
8648
|
+
Uint8Array: inspectTypedArray,
|
|
8649
|
+
Uint8ClampedArray: inspectTypedArray,
|
|
8650
|
+
Int16Array: inspectTypedArray,
|
|
8651
|
+
Uint16Array: inspectTypedArray,
|
|
8652
|
+
Int32Array: inspectTypedArray,
|
|
8653
|
+
Uint32Array: inspectTypedArray,
|
|
8654
|
+
Float32Array: inspectTypedArray,
|
|
8655
|
+
Float64Array: inspectTypedArray,
|
|
8656
|
+
Generator: /* @__PURE__ */ __name(()=>"", "Generator"),
|
|
8657
|
+
DataView: /* @__PURE__ */ __name(()=>"", "DataView"),
|
|
8658
|
+
ArrayBuffer: /* @__PURE__ */ __name(()=>"", "ArrayBuffer"),
|
|
8659
|
+
Error: inspectObject2,
|
|
8660
|
+
HTMLCollection: inspectNodeCollection,
|
|
8661
|
+
NodeList: inspectNodeCollection
|
|
8662
|
+
};
|
|
8663
|
+
var inspectCustom = /* @__PURE__ */ __name((value, options, type3)=>{
|
|
8664
|
+
if (chaiInspect in value && "function" == typeof value[chaiInspect]) return value[chaiInspect](options);
|
|
8665
|
+
if (nodeInspect in value && "function" == typeof value[nodeInspect]) return value[nodeInspect](options.depth, options);
|
|
8666
|
+
if ("inspect" in value && "function" == typeof value.inspect) return value.inspect(options.depth, options);
|
|
8667
|
+
if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
|
|
8668
|
+
if (stringTagMap[type3]) return stringTagMap[type3](value, options);
|
|
8669
|
+
return "";
|
|
8670
|
+
}, "inspectCustom");
|
|
8671
|
+
var toString = Object.prototype.toString;
|
|
8672
|
+
function inspect(value, opts = {}) {
|
|
8673
|
+
const options = normaliseOptions(opts, inspect);
|
|
8674
|
+
const { customInspect } = options;
|
|
8675
|
+
let type3 = null === value ? "null" : typeof value;
|
|
8676
|
+
if ("object" === type3) type3 = toString.call(value).slice(8, -1);
|
|
8677
|
+
if (type3 in baseTypesMap) return baseTypesMap[type3](value, options);
|
|
8678
|
+
if (customInspect && value) {
|
|
8679
|
+
const output = inspectCustom(value, options, type3);
|
|
8680
|
+
if (output) {
|
|
8681
|
+
if ("string" == typeof output) return output;
|
|
8682
|
+
return inspect(output, options);
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8685
|
+
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
8686
|
+
if (proto === Object.prototype || null === proto) return inspectObject(value, options);
|
|
8687
|
+
if (value && "function" == typeof HTMLElement && value instanceof HTMLElement) return inspectHTML(value, options);
|
|
8688
|
+
if ("constructor" in value) {
|
|
8689
|
+
if (value.constructor !== Object) return inspectClass(value, options);
|
|
8690
|
+
return inspectObject(value, options);
|
|
8691
|
+
}
|
|
8692
|
+
if (value === Object(value)) return inspectObject(value, options);
|
|
8693
|
+
return options.stylize(String(value), type3);
|
|
8694
|
+
}
|
|
8695
|
+
__name(inspect, "inspect");
|
|
8696
|
+
var config = {
|
|
8697
|
+
includeStack: false,
|
|
8698
|
+
showDiff: true,
|
|
8699
|
+
truncateThreshold: 40,
|
|
8700
|
+
useProxy: true,
|
|
8701
|
+
proxyExcludedKeys: [
|
|
8702
|
+
"then",
|
|
8703
|
+
"catch",
|
|
8704
|
+
"inspect",
|
|
8705
|
+
"toJSON"
|
|
8706
|
+
],
|
|
8707
|
+
deepEqual: null
|
|
8708
|
+
};
|
|
8709
|
+
function inspect2(obj, showHidden, depth, colors) {
|
|
8710
|
+
let options = {
|
|
8711
|
+
colors,
|
|
8712
|
+
depth: void 0 === depth ? 2 : depth,
|
|
8713
|
+
showHidden,
|
|
8714
|
+
truncate: config.truncateThreshold ? config.truncateThreshold : 1 / 0
|
|
8715
|
+
};
|
|
8716
|
+
return inspect(obj, options);
|
|
8717
|
+
}
|
|
8718
|
+
__name(inspect2, "inspect");
|
|
8719
|
+
function objDisplay(obj) {
|
|
8720
|
+
let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
|
|
8721
|
+
if (!config.truncateThreshold || !(str.length >= config.truncateThreshold)) return str;
|
|
8722
|
+
if ("[object Function]" === type3) return obj.name && "" !== obj.name ? "[Function: " + obj.name + "]" : "[Function]";
|
|
8723
|
+
if ("[object Array]" === type3) return "[ Array(" + obj.length + ") ]";
|
|
8724
|
+
{
|
|
8725
|
+
if ("[object Object]" !== type3) return str;
|
|
8726
|
+
let keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
|
|
8727
|
+
return "{ Object (" + kstr + ") }";
|
|
8728
|
+
}
|
|
8729
|
+
}
|
|
8730
|
+
__name(objDisplay, "objDisplay");
|
|
8731
|
+
function getMessage2(obj, args) {
|
|
8732
|
+
let negate = flag(obj, "negate");
|
|
8733
|
+
let val = flag(obj, "object");
|
|
8734
|
+
let expected = args[3];
|
|
8735
|
+
let actual = getActual(obj, args);
|
|
8736
|
+
let msg = negate ? args[2] : args[1];
|
|
8737
|
+
let flagMsg = flag(obj, "message");
|
|
8738
|
+
if ("function" == typeof msg) msg = msg();
|
|
8739
|
+
msg = msg || "";
|
|
8740
|
+
msg = msg.replace(/#\{this\}/g, function() {
|
|
8741
|
+
return objDisplay(val);
|
|
8742
|
+
}).replace(/#\{act\}/g, function() {
|
|
8743
|
+
return objDisplay(actual);
|
|
8744
|
+
}).replace(/#\{exp\}/g, function() {
|
|
8745
|
+
return objDisplay(expected);
|
|
8746
|
+
});
|
|
8747
|
+
return flagMsg ? flagMsg + ": " + msg : msg;
|
|
8748
|
+
}
|
|
8749
|
+
__name(getMessage2, "getMessage");
|
|
8750
|
+
function transferFlags(assertion, object, includeAll) {
|
|
8751
|
+
let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
8752
|
+
if (!object.__flags) object.__flags = /* @__PURE__ */ Object.create(null);
|
|
8753
|
+
includeAll = 3 === arguments.length ? includeAll : true;
|
|
8754
|
+
for(let flag3 in flags)if (includeAll || "object" !== flag3 && "ssfi" !== flag3 && "lockSsfi" !== flag3 && "message" != flag3) object.__flags[flag3] = flags[flag3];
|
|
8755
|
+
}
|
|
8756
|
+
__name(transferFlags, "transferFlags");
|
|
8757
|
+
function type2(obj) {
|
|
8758
|
+
if (void 0 === obj) return "undefined";
|
|
8759
|
+
if (null === obj) return "null";
|
|
8760
|
+
const stringTag = obj[Symbol.toStringTag];
|
|
8761
|
+
if ("string" == typeof stringTag) return stringTag;
|
|
8762
|
+
const sliceStart = 8;
|
|
8763
|
+
const sliceEnd = -1;
|
|
8764
|
+
return Object.prototype.toString.call(obj).slice(sliceStart, sliceEnd);
|
|
8765
|
+
}
|
|
8766
|
+
__name(type2, "type");
|
|
8767
|
+
function FakeMap() {
|
|
8768
|
+
this._key = "chai/deep-eql__" + Math.random() + Date.now();
|
|
8769
|
+
}
|
|
8770
|
+
__name(FakeMap, "FakeMap");
|
|
8771
|
+
FakeMap.prototype = {
|
|
8772
|
+
get: /* @__PURE__ */ __name(function get(key) {
|
|
8773
|
+
return key[this._key];
|
|
8774
|
+
}, "get"),
|
|
8775
|
+
set: /* @__PURE__ */ __name(function set(key, value) {
|
|
8776
|
+
if (Object.isExtensible(key)) Object.defineProperty(key, this._key, {
|
|
8777
|
+
value,
|
|
8778
|
+
configurable: true
|
|
8779
|
+
});
|
|
8780
|
+
}, "set")
|
|
8781
|
+
};
|
|
8782
|
+
var MemoizeMap = "function" == typeof WeakMap ? WeakMap : FakeMap;
|
|
8783
|
+
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
|
|
8784
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return null;
|
|
8785
|
+
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
8786
|
+
if (leftHandMap) {
|
|
8787
|
+
var result = leftHandMap.get(rightHandOperand);
|
|
8788
|
+
if ("boolean" == typeof result) return result;
|
|
8789
|
+
}
|
|
8790
|
+
return null;
|
|
8791
|
+
}
|
|
8792
|
+
__name(memoizeCompare, "memoizeCompare");
|
|
8793
|
+
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
|
8794
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return;
|
|
8795
|
+
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
8796
|
+
if (leftHandMap) leftHandMap.set(rightHandOperand, result);
|
|
8797
|
+
else {
|
|
8798
|
+
leftHandMap = new MemoizeMap();
|
|
8799
|
+
leftHandMap.set(rightHandOperand, result);
|
|
8800
|
+
memoizeMap.set(leftHandOperand, leftHandMap);
|
|
8801
|
+
}
|
|
8802
|
+
}
|
|
8803
|
+
__name(memoizeSet, "memoizeSet");
|
|
8804
|
+
var deep_eql_default = deepEqual;
|
|
8805
|
+
function deepEqual(leftHandOperand, rightHandOperand, options) {
|
|
8806
|
+
if (options && options.comparator) return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
8807
|
+
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
8808
|
+
if (null !== simpleResult) return simpleResult;
|
|
8809
|
+
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
8810
|
+
}
|
|
8811
|
+
__name(deepEqual, "deepEqual");
|
|
8812
|
+
function simpleEqual(leftHandOperand, rightHandOperand) {
|
|
8813
|
+
if (leftHandOperand === rightHandOperand) return 0 !== leftHandOperand || 1 / leftHandOperand === 1 / rightHandOperand;
|
|
8814
|
+
if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) return true;
|
|
8815
|
+
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return false;
|
|
8816
|
+
return null;
|
|
8817
|
+
}
|
|
8818
|
+
__name(simpleEqual, "simpleEqual");
|
|
8819
|
+
function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
|
8820
|
+
options = options || {};
|
|
8821
|
+
options.memoize = false === options.memoize ? false : options.memoize || new MemoizeMap();
|
|
8822
|
+
var comparator = options && options.comparator;
|
|
8823
|
+
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
|
|
8824
|
+
if (null !== memoizeResultLeft) return memoizeResultLeft;
|
|
8825
|
+
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
|
|
8826
|
+
if (null !== memoizeResultRight) return memoizeResultRight;
|
|
8827
|
+
if (comparator) {
|
|
8828
|
+
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
|
|
8829
|
+
if (false === comparatorResult || true === comparatorResult) {
|
|
8830
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
|
|
8831
|
+
return comparatorResult;
|
|
8832
|
+
}
|
|
8833
|
+
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
8834
|
+
if (null !== simpleResult) return simpleResult;
|
|
8835
|
+
}
|
|
8836
|
+
var leftHandType = type2(leftHandOperand);
|
|
8837
|
+
if (leftHandType !== type2(rightHandOperand)) {
|
|
8838
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
|
|
8839
|
+
return false;
|
|
8840
|
+
}
|
|
8841
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
|
|
8842
|
+
var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
|
|
8843
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
|
|
8844
|
+
return result;
|
|
8845
|
+
}
|
|
8846
|
+
__name(extensiveDeepEqual, "extensiveDeepEqual");
|
|
8847
|
+
function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
|
|
8848
|
+
switch(leftHandType){
|
|
8849
|
+
case "String":
|
|
8850
|
+
case "Number":
|
|
8851
|
+
case "Boolean":
|
|
8852
|
+
case "Date":
|
|
8853
|
+
return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
|
|
8854
|
+
case "Promise":
|
|
8855
|
+
case "Symbol":
|
|
8856
|
+
case "function":
|
|
8857
|
+
case "WeakMap":
|
|
8858
|
+
case "WeakSet":
|
|
8859
|
+
return leftHandOperand === rightHandOperand;
|
|
8860
|
+
case "Error":
|
|
8861
|
+
return keysEqual(leftHandOperand, rightHandOperand, [
|
|
8862
|
+
"name",
|
|
8863
|
+
"message",
|
|
8864
|
+
"code"
|
|
8865
|
+
], options);
|
|
8866
|
+
case "Arguments":
|
|
8867
|
+
case "Int8Array":
|
|
8868
|
+
case "Uint8Array":
|
|
8869
|
+
case "Uint8ClampedArray":
|
|
8870
|
+
case "Int16Array":
|
|
8871
|
+
case "Uint16Array":
|
|
8872
|
+
case "Int32Array":
|
|
8873
|
+
case "Uint32Array":
|
|
8874
|
+
case "Float32Array":
|
|
8875
|
+
case "Float64Array":
|
|
8876
|
+
case "Array":
|
|
8877
|
+
return iterableEqual(leftHandOperand, rightHandOperand, options);
|
|
8878
|
+
case "RegExp":
|
|
8879
|
+
return regexpEqual(leftHandOperand, rightHandOperand);
|
|
8880
|
+
case "Generator":
|
|
8881
|
+
return generatorEqual(leftHandOperand, rightHandOperand, options);
|
|
8882
|
+
case "DataView":
|
|
8883
|
+
return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
|
|
8884
|
+
case "ArrayBuffer":
|
|
8885
|
+
return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
|
|
8886
|
+
case "Set":
|
|
8887
|
+
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
8888
|
+
case "Map":
|
|
8889
|
+
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
8890
|
+
case "Temporal.PlainDate":
|
|
8891
|
+
case "Temporal.PlainTime":
|
|
8892
|
+
case "Temporal.PlainDateTime":
|
|
8893
|
+
case "Temporal.Instant":
|
|
8894
|
+
case "Temporal.ZonedDateTime":
|
|
8895
|
+
case "Temporal.PlainYearMonth":
|
|
8896
|
+
case "Temporal.PlainMonthDay":
|
|
8897
|
+
return leftHandOperand.equals(rightHandOperand);
|
|
8898
|
+
case "Temporal.Duration":
|
|
8899
|
+
return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
|
|
8900
|
+
case "Temporal.TimeZone":
|
|
8901
|
+
case "Temporal.Calendar":
|
|
8902
|
+
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
8903
|
+
default:
|
|
8904
|
+
return objectEqual(leftHandOperand, rightHandOperand, options);
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
__name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
|
|
8908
|
+
function regexpEqual(leftHandOperand, rightHandOperand) {
|
|
8909
|
+
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
8910
|
+
}
|
|
8911
|
+
__name(regexpEqual, "regexpEqual");
|
|
8912
|
+
function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
|
8913
|
+
try {
|
|
8914
|
+
if (leftHandOperand.size !== rightHandOperand.size) return false;
|
|
8915
|
+
if (0 === leftHandOperand.size) return true;
|
|
8916
|
+
} catch (sizeError) {
|
|
8917
|
+
return false;
|
|
8918
|
+
}
|
|
8919
|
+
var leftHandItems = [];
|
|
8920
|
+
var rightHandItems = [];
|
|
8921
|
+
leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
8922
|
+
leftHandItems.push([
|
|
8923
|
+
key,
|
|
8924
|
+
value
|
|
8925
|
+
]);
|
|
8926
|
+
}, "gatherEntries"));
|
|
8927
|
+
rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
8928
|
+
rightHandItems.push([
|
|
8929
|
+
key,
|
|
8930
|
+
value
|
|
8931
|
+
]);
|
|
8932
|
+
}, "gatherEntries"));
|
|
8933
|
+
return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
|
|
8934
|
+
}
|
|
8935
|
+
__name(entriesEqual, "entriesEqual");
|
|
8936
|
+
function iterableEqual(leftHandOperand, rightHandOperand, options) {
|
|
8937
|
+
var length = leftHandOperand.length;
|
|
8938
|
+
if (length !== rightHandOperand.length) return false;
|
|
8939
|
+
if (0 === length) return true;
|
|
8940
|
+
var index = -1;
|
|
8941
|
+
while(++index < length)if (false === deepEqual(leftHandOperand[index], rightHandOperand[index], options)) return false;
|
|
8942
|
+
return true;
|
|
8943
|
+
}
|
|
8944
|
+
__name(iterableEqual, "iterableEqual");
|
|
8945
|
+
function generatorEqual(leftHandOperand, rightHandOperand, options) {
|
|
8946
|
+
return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
|
|
8947
|
+
}
|
|
8948
|
+
__name(generatorEqual, "generatorEqual");
|
|
8949
|
+
function hasIteratorFunction(target) {
|
|
8950
|
+
return "undefined" != typeof Symbol && "object" == typeof target && void 0 !== Symbol.iterator && "function" == typeof target[Symbol.iterator];
|
|
8951
|
+
}
|
|
8952
|
+
__name(hasIteratorFunction, "hasIteratorFunction");
|
|
8953
|
+
function getIteratorEntries(target) {
|
|
8954
|
+
if (hasIteratorFunction(target)) try {
|
|
8955
|
+
return getGeneratorEntries(target[Symbol.iterator]());
|
|
8956
|
+
} catch (iteratorError) {}
|
|
8957
|
+
return [];
|
|
8958
|
+
}
|
|
8959
|
+
__name(getIteratorEntries, "getIteratorEntries");
|
|
8960
|
+
function getGeneratorEntries(generator) {
|
|
8961
|
+
var generatorResult = generator.next();
|
|
8962
|
+
var accumulator = [
|
|
8963
|
+
generatorResult.value
|
|
8964
|
+
];
|
|
8965
|
+
while(false === generatorResult.done){
|
|
8966
|
+
generatorResult = generator.next();
|
|
8967
|
+
accumulator.push(generatorResult.value);
|
|
8968
|
+
}
|
|
8969
|
+
return accumulator;
|
|
8970
|
+
}
|
|
8971
|
+
__name(getGeneratorEntries, "getGeneratorEntries");
|
|
8972
|
+
function getEnumerableKeys(target) {
|
|
8973
|
+
var keys = [];
|
|
8974
|
+
for(var key in target)keys.push(key);
|
|
8975
|
+
return keys;
|
|
8976
|
+
}
|
|
8977
|
+
__name(getEnumerableKeys, "getEnumerableKeys");
|
|
8978
|
+
function getEnumerableSymbols(target) {
|
|
8979
|
+
var keys = [];
|
|
8980
|
+
var allKeys = Object.getOwnPropertySymbols(target);
|
|
8981
|
+
for(var i = 0; i < allKeys.length; i += 1){
|
|
8982
|
+
var key = allKeys[i];
|
|
8983
|
+
if (Object.getOwnPropertyDescriptor(target, key).enumerable) keys.push(key);
|
|
8984
|
+
}
|
|
8985
|
+
return keys;
|
|
8986
|
+
}
|
|
8987
|
+
__name(getEnumerableSymbols, "getEnumerableSymbols");
|
|
8988
|
+
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
|
8989
|
+
var length = keys.length;
|
|
8990
|
+
if (0 === length) return true;
|
|
8991
|
+
for(var i = 0; i < length; i += 1)if (false === deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options)) return false;
|
|
8992
|
+
return true;
|
|
8993
|
+
}
|
|
8994
|
+
__name(keysEqual, "keysEqual");
|
|
8995
|
+
function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
8996
|
+
var leftHandKeys = getEnumerableKeys(leftHandOperand);
|
|
8997
|
+
var rightHandKeys = getEnumerableKeys(rightHandOperand);
|
|
8998
|
+
var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
|
|
8999
|
+
var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
|
|
9000
|
+
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
|
9001
|
+
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
|
9002
|
+
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
|
|
9003
|
+
if (false === iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort())) return false;
|
|
9004
|
+
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
|
|
9005
|
+
}
|
|
9006
|
+
var leftHandEntries = getIteratorEntries(leftHandOperand);
|
|
9007
|
+
var rightHandEntries = getIteratorEntries(rightHandOperand);
|
|
9008
|
+
if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
|
|
9009
|
+
leftHandEntries.sort();
|
|
9010
|
+
rightHandEntries.sort();
|
|
9011
|
+
return iterableEqual(leftHandEntries, rightHandEntries, options);
|
|
9012
|
+
}
|
|
9013
|
+
if (0 === leftHandKeys.length && 0 === leftHandEntries.length && 0 === rightHandKeys.length && 0 === rightHandEntries.length) return true;
|
|
9014
|
+
return false;
|
|
9015
|
+
}
|
|
9016
|
+
__name(objectEqual, "objectEqual");
|
|
9017
|
+
function isPrimitive(value) {
|
|
9018
|
+
return null === value || "object" != typeof value;
|
|
9019
|
+
}
|
|
9020
|
+
__name(isPrimitive, "isPrimitive");
|
|
9021
|
+
function mapSymbols(arr) {
|
|
9022
|
+
return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
|
|
9023
|
+
if ("symbol" == typeof entry) return entry.toString();
|
|
9024
|
+
return entry;
|
|
9025
|
+
}, "mapSymbol"));
|
|
9026
|
+
}
|
|
9027
|
+
__name(mapSymbols, "mapSymbols");
|
|
9028
|
+
function hasProperty(obj, name) {
|
|
9029
|
+
if (null == obj) return false;
|
|
9030
|
+
return name in Object(obj);
|
|
9031
|
+
}
|
|
9032
|
+
__name(hasProperty, "hasProperty");
|
|
9033
|
+
function parsePath(path) {
|
|
9034
|
+
const str = path.replace(/([^\\])\[/g, "$1.[");
|
|
9035
|
+
const parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
9036
|
+
return parts.map((value)=>{
|
|
9037
|
+
if ("constructor" === value || "__proto__" === value || "prototype" === value) return {};
|
|
9038
|
+
const regexp = /^\[(\d+)\]$/;
|
|
9039
|
+
const mArr = regexp.exec(value);
|
|
9040
|
+
let parsed = null;
|
|
9041
|
+
parsed = mArr ? {
|
|
9042
|
+
i: parseFloat(mArr[1])
|
|
9043
|
+
} : {
|
|
9044
|
+
p: value.replace(/\\([.[\]])/g, "$1")
|
|
9045
|
+
};
|
|
9046
|
+
return parsed;
|
|
9047
|
+
});
|
|
9048
|
+
}
|
|
9049
|
+
__name(parsePath, "parsePath");
|
|
9050
|
+
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
9051
|
+
let temporaryValue = obj;
|
|
9052
|
+
let res = null;
|
|
9053
|
+
pathDepth = void 0 === pathDepth ? parsed.length : pathDepth;
|
|
9054
|
+
for(let i = 0; i < pathDepth; i++){
|
|
9055
|
+
const part = parsed[i];
|
|
9056
|
+
if (temporaryValue) {
|
|
9057
|
+
temporaryValue = void 0 === part.p ? temporaryValue[part.i] : temporaryValue[part.p];
|
|
9058
|
+
if (i === pathDepth - 1) res = temporaryValue;
|
|
9059
|
+
}
|
|
9060
|
+
}
|
|
9061
|
+
return res;
|
|
9062
|
+
}
|
|
9063
|
+
__name(internalGetPathValue, "internalGetPathValue");
|
|
9064
|
+
function getPathInfo(obj, path) {
|
|
9065
|
+
const parsed = parsePath(path);
|
|
9066
|
+
const last = parsed[parsed.length - 1];
|
|
9067
|
+
const info = {
|
|
9068
|
+
parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
|
|
9069
|
+
name: last.p || last.i,
|
|
9070
|
+
value: internalGetPathValue(obj, parsed)
|
|
9071
|
+
};
|
|
9072
|
+
info.exists = hasProperty(info.parent, info.name);
|
|
9073
|
+
return info;
|
|
9074
|
+
}
|
|
9075
|
+
__name(getPathInfo, "getPathInfo");
|
|
9076
|
+
var Assertion = class _Assertion {
|
|
9077
|
+
static{
|
|
9078
|
+
__name(this, "Assertion");
|
|
9079
|
+
}
|
|
9080
|
+
__flags = {};
|
|
9081
|
+
constructor(obj, msg, ssfi, lockSsfi){
|
|
9082
|
+
flag(this, "ssfi", ssfi || _Assertion);
|
|
9083
|
+
flag(this, "lockSsfi", lockSsfi);
|
|
9084
|
+
flag(this, "object", obj);
|
|
9085
|
+
flag(this, "message", msg);
|
|
9086
|
+
flag(this, "eql", config.deepEqual || deep_eql_default);
|
|
9087
|
+
return proxify(this);
|
|
9088
|
+
}
|
|
9089
|
+
static get includeStack() {
|
|
9090
|
+
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
9091
|
+
return config.includeStack;
|
|
9092
|
+
}
|
|
9093
|
+
static set includeStack(value) {
|
|
9094
|
+
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
9095
|
+
config.includeStack = value;
|
|
9096
|
+
}
|
|
9097
|
+
static get showDiff() {
|
|
9098
|
+
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
9099
|
+
return config.showDiff;
|
|
9100
|
+
}
|
|
9101
|
+
static set showDiff(value) {
|
|
9102
|
+
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
9103
|
+
config.showDiff = value;
|
|
9104
|
+
}
|
|
9105
|
+
static addProperty(name, fn) {
|
|
9106
|
+
addProperty(this.prototype, name, fn);
|
|
9107
|
+
}
|
|
9108
|
+
static addMethod(name, fn) {
|
|
9109
|
+
addMethod(this.prototype, name, fn);
|
|
9110
|
+
}
|
|
9111
|
+
static addChainableMethod(name, fn, chainingBehavior) {
|
|
9112
|
+
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
9113
|
+
}
|
|
9114
|
+
static overwriteProperty(name, fn) {
|
|
9115
|
+
overwriteProperty(this.prototype, name, fn);
|
|
9116
|
+
}
|
|
9117
|
+
static overwriteMethod(name, fn) {
|
|
9118
|
+
overwriteMethod(this.prototype, name, fn);
|
|
9119
|
+
}
|
|
9120
|
+
static overwriteChainableMethod(name, fn, chainingBehavior) {
|
|
9121
|
+
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
9122
|
+
}
|
|
9123
|
+
assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
|
|
9124
|
+
const ok = test(this, arguments);
|
|
9125
|
+
if (false !== showDiff) showDiff = true;
|
|
9126
|
+
if (void 0 === expected && void 0 === _actual) showDiff = false;
|
|
9127
|
+
if (true !== config.showDiff) showDiff = false;
|
|
9128
|
+
if (!ok) {
|
|
9129
|
+
msg = getMessage2(this, arguments);
|
|
9130
|
+
const actual = getActual(this, arguments);
|
|
9131
|
+
const assertionErrorObjectProperties = {
|
|
9132
|
+
actual,
|
|
9133
|
+
expected,
|
|
9134
|
+
showDiff
|
|
9135
|
+
};
|
|
9136
|
+
const operator = getOperator(this, arguments);
|
|
9137
|
+
if (operator) assertionErrorObjectProperties.operator = operator;
|
|
9138
|
+
throw new AssertionError(msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi"));
|
|
9139
|
+
}
|
|
9140
|
+
}
|
|
9141
|
+
get _obj() {
|
|
9142
|
+
return flag(this, "object");
|
|
9143
|
+
}
|
|
9144
|
+
set _obj(val) {
|
|
9145
|
+
flag(this, "object", val);
|
|
9146
|
+
}
|
|
9147
|
+
};
|
|
9148
|
+
function isProxyEnabled() {
|
|
9149
|
+
return config.useProxy && "undefined" != typeof Proxy && "undefined" != typeof Reflect;
|
|
9150
|
+
}
|
|
9151
|
+
__name(isProxyEnabled, "isProxyEnabled");
|
|
9152
|
+
function addProperty(ctx, name, getter) {
|
|
9153
|
+
getter = void 0 === getter ? function() {} : getter;
|
|
9154
|
+
Object.defineProperty(ctx, name, {
|
|
9155
|
+
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
9156
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", propertyGetter);
|
|
9157
|
+
let result = getter.call(this);
|
|
9158
|
+
if (void 0 !== result) return result;
|
|
9159
|
+
let newAssertion = new Assertion();
|
|
9160
|
+
transferFlags(this, newAssertion);
|
|
9161
|
+
return newAssertion;
|
|
9162
|
+
}, "propertyGetter"),
|
|
9163
|
+
configurable: true
|
|
9164
|
+
});
|
|
9165
|
+
}
|
|
9166
|
+
__name(addProperty, "addProperty");
|
|
9167
|
+
var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
|
|
9168
|
+
function addLengthGuard(fn, assertionName, isChainable) {
|
|
9169
|
+
if (!fnLengthDesc.configurable) return fn;
|
|
9170
|
+
Object.defineProperty(fn, "length", {
|
|
9171
|
+
get: /* @__PURE__ */ __name(function() {
|
|
9172
|
+
if (isChainable) throw Error("Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.');
|
|
9173
|
+
throw Error("Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".');
|
|
9174
|
+
}, "get")
|
|
9175
|
+
});
|
|
9176
|
+
return fn;
|
|
9177
|
+
}
|
|
9178
|
+
__name(addLengthGuard, "addLengthGuard");
|
|
9179
|
+
function getProperties(object) {
|
|
9180
|
+
let result = Object.getOwnPropertyNames(object);
|
|
9181
|
+
function addProperty2(property) {
|
|
9182
|
+
if (-1 === result.indexOf(property)) result.push(property);
|
|
9183
|
+
}
|
|
9184
|
+
__name(addProperty2, "addProperty");
|
|
9185
|
+
let proto = Object.getPrototypeOf(object);
|
|
9186
|
+
while(null !== proto){
|
|
9187
|
+
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
9188
|
+
proto = Object.getPrototypeOf(proto);
|
|
9189
|
+
}
|
|
9190
|
+
return result;
|
|
9191
|
+
}
|
|
9192
|
+
__name(getProperties, "getProperties");
|
|
9193
|
+
var builtins = [
|
|
9194
|
+
"__flags",
|
|
9195
|
+
"__methods",
|
|
9196
|
+
"_obj",
|
|
9197
|
+
"assert"
|
|
9198
|
+
];
|
|
9199
|
+
function proxify(obj, nonChainableMethodName) {
|
|
9200
|
+
if (!isProxyEnabled()) return obj;
|
|
9201
|
+
return new Proxy(obj, {
|
|
9202
|
+
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
9203
|
+
if ("string" == typeof property && -1 === config.proxyExcludedKeys.indexOf(property) && !Reflect.has(target, property)) {
|
|
9204
|
+
if (nonChainableMethodName) throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".');
|
|
9205
|
+
let suggestion = null;
|
|
9206
|
+
let suggestionDistance = 4;
|
|
9207
|
+
getProperties(target).forEach(function(prop) {
|
|
9208
|
+
if (!Object.prototype.hasOwnProperty(prop) && -1 === builtins.indexOf(prop)) {
|
|
9209
|
+
let dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
9210
|
+
if (dist < suggestionDistance) {
|
|
9211
|
+
suggestion = prop;
|
|
9212
|
+
suggestionDistance = dist;
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
9215
|
+
});
|
|
9216
|
+
if (null !== suggestion) throw Error("Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?');
|
|
9217
|
+
throw Error("Invalid Chai property: " + property);
|
|
9218
|
+
}
|
|
9219
|
+
if (-1 === builtins.indexOf(property) && !flag(target, "lockSsfi")) flag(target, "ssfi", proxyGetter);
|
|
9220
|
+
return Reflect.get(target, property);
|
|
9221
|
+
}, "proxyGetter")
|
|
9222
|
+
});
|
|
9223
|
+
}
|
|
9224
|
+
__name(proxify, "proxify");
|
|
9225
|
+
function stringDistanceCapped(strA, strB, cap) {
|
|
9226
|
+
if (Math.abs(strA.length - strB.length) >= cap) return cap;
|
|
9227
|
+
let memo = [];
|
|
9228
|
+
for(let i = 0; i <= strA.length; i++){
|
|
9229
|
+
memo[i] = Array(strB.length + 1).fill(0);
|
|
9230
|
+
memo[i][0] = i;
|
|
9231
|
+
}
|
|
9232
|
+
for(let j = 0; j < strB.length; j++)memo[0][j] = j;
|
|
9233
|
+
for(let i = 1; i <= strA.length; i++){
|
|
9234
|
+
let ch = strA.charCodeAt(i - 1);
|
|
9235
|
+
for(let j = 1; j <= strB.length; j++){
|
|
9236
|
+
if (Math.abs(i - j) >= cap) {
|
|
9237
|
+
memo[i][j] = cap;
|
|
9238
|
+
continue;
|
|
9239
|
+
}
|
|
9240
|
+
memo[i][j] = Math.min(memo[i - 1][j] + 1, memo[i][j - 1] + 1, memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1));
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
return memo[strA.length][strB.length];
|
|
9244
|
+
}
|
|
9245
|
+
__name(stringDistanceCapped, "stringDistanceCapped");
|
|
9246
|
+
function addMethod(ctx, name, method) {
|
|
9247
|
+
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
9248
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", methodWrapper);
|
|
9249
|
+
let result = method.apply(this, arguments);
|
|
9250
|
+
if (void 0 !== result) return result;
|
|
9251
|
+
let newAssertion = new Assertion();
|
|
9252
|
+
transferFlags(this, newAssertion);
|
|
9253
|
+
return newAssertion;
|
|
9254
|
+
}, "methodWrapper");
|
|
9255
|
+
addLengthGuard(methodWrapper, name, false);
|
|
9256
|
+
ctx[name] = proxify(methodWrapper, name);
|
|
9257
|
+
}
|
|
9258
|
+
__name(addMethod, "addMethod");
|
|
9259
|
+
function overwriteProperty(ctx, name, getter) {
|
|
9260
|
+
let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {}, "_super");
|
|
9261
|
+
if (_get && "function" == typeof _get.get) _super = _get.get;
|
|
9262
|
+
Object.defineProperty(ctx, name, {
|
|
9263
|
+
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
9264
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", overwritingPropertyGetter);
|
|
9265
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
9266
|
+
flag(this, "lockSsfi", true);
|
|
9267
|
+
let result = getter(_super).call(this);
|
|
9268
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
9269
|
+
if (void 0 !== result) return result;
|
|
9270
|
+
let newAssertion = new Assertion();
|
|
9271
|
+
transferFlags(this, newAssertion);
|
|
9272
|
+
return newAssertion;
|
|
9273
|
+
}, "overwritingPropertyGetter"),
|
|
9274
|
+
configurable: true
|
|
9275
|
+
});
|
|
9276
|
+
}
|
|
9277
|
+
__name(overwriteProperty, "overwriteProperty");
|
|
9278
|
+
function overwriteMethod(ctx, name, method) {
|
|
9279
|
+
let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
9280
|
+
throw new Error(name + " is not a function");
|
|
9281
|
+
}, "_super");
|
|
9282
|
+
if (_method && "function" == typeof _method) _super = _method;
|
|
9283
|
+
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
9284
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", overwritingMethodWrapper);
|
|
9285
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
9286
|
+
flag(this, "lockSsfi", true);
|
|
9287
|
+
let result = method(_super).apply(this, arguments);
|
|
9288
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
9289
|
+
if (void 0 !== result) return result;
|
|
9290
|
+
let newAssertion = new Assertion();
|
|
9291
|
+
transferFlags(this, newAssertion);
|
|
9292
|
+
return newAssertion;
|
|
9293
|
+
}, "overwritingMethodWrapper");
|
|
9294
|
+
addLengthGuard(overwritingMethodWrapper, name, false);
|
|
9295
|
+
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
9296
|
+
}
|
|
9297
|
+
__name(overwriteMethod, "overwriteMethod");
|
|
9298
|
+
var canSetPrototype = "function" == typeof Object.setPrototypeOf;
|
|
9299
|
+
var testFn = /* @__PURE__ */ __name(function() {}, "testFn");
|
|
9300
|
+
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
9301
|
+
let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
9302
|
+
if ("object" != typeof propDesc) return true;
|
|
9303
|
+
return !propDesc.configurable;
|
|
9304
|
+
});
|
|
9305
|
+
var call = Function.prototype.call;
|
|
9306
|
+
var apply = Function.prototype.apply;
|
|
9307
|
+
function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
9308
|
+
if ("function" != typeof chainingBehavior) chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
|
|
9309
|
+
let chainableBehavior = {
|
|
9310
|
+
method,
|
|
9311
|
+
chainingBehavior
|
|
9312
|
+
};
|
|
9313
|
+
if (!ctx.__methods) ctx.__methods = {};
|
|
9314
|
+
ctx.__methods[name] = chainableBehavior;
|
|
9315
|
+
Object.defineProperty(ctx, name, {
|
|
9316
|
+
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
9317
|
+
chainableBehavior.chainingBehavior.call(this);
|
|
9318
|
+
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
9319
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", chainableMethodWrapper);
|
|
9320
|
+
let result = chainableBehavior.method.apply(this, arguments);
|
|
9321
|
+
if (void 0 !== result) return result;
|
|
9322
|
+
let newAssertion = new Assertion();
|
|
9323
|
+
transferFlags(this, newAssertion);
|
|
9324
|
+
return newAssertion;
|
|
9325
|
+
}, "chainableMethodWrapper");
|
|
9326
|
+
addLengthGuard(chainableMethodWrapper, name, true);
|
|
9327
|
+
if (canSetPrototype) {
|
|
9328
|
+
let prototype = Object.create(this);
|
|
9329
|
+
prototype.call = call;
|
|
9330
|
+
prototype.apply = apply;
|
|
9331
|
+
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
9332
|
+
} else {
|
|
9333
|
+
let asserterNames = Object.getOwnPropertyNames(ctx);
|
|
9334
|
+
asserterNames.forEach(function(asserterName) {
|
|
9335
|
+
if (-1 !== excludeNames.indexOf(asserterName)) return;
|
|
9336
|
+
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
9337
|
+
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
9338
|
+
});
|
|
9339
|
+
}
|
|
9340
|
+
transferFlags(this, chainableMethodWrapper);
|
|
9341
|
+
return proxify(chainableMethodWrapper);
|
|
9342
|
+
}, "chainableMethodGetter"),
|
|
9343
|
+
configurable: true
|
|
9344
|
+
});
|
|
9345
|
+
}
|
|
9346
|
+
__name(addChainableMethod, "addChainableMethod");
|
|
9347
|
+
function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
9348
|
+
let chainableBehavior = ctx.__methods[name];
|
|
9349
|
+
let _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
9350
|
+
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
9351
|
+
let result = chainingBehavior(_chainingBehavior).call(this);
|
|
9352
|
+
if (void 0 !== result) return result;
|
|
9353
|
+
let newAssertion = new Assertion();
|
|
9354
|
+
transferFlags(this, newAssertion);
|
|
9355
|
+
return newAssertion;
|
|
9356
|
+
}, "overwritingChainableMethodGetter");
|
|
9357
|
+
let _method = chainableBehavior.method;
|
|
9358
|
+
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
9359
|
+
let result = method(_method).apply(this, arguments);
|
|
9360
|
+
if (void 0 !== result) return result;
|
|
9361
|
+
let newAssertion = new Assertion();
|
|
9362
|
+
transferFlags(this, newAssertion);
|
|
9363
|
+
return newAssertion;
|
|
9364
|
+
}, "overwritingChainableMethodWrapper");
|
|
9365
|
+
}
|
|
9366
|
+
__name(overwriteChainableMethod, "overwriteChainableMethod");
|
|
9367
|
+
function compareByInspect(a, b) {
|
|
9368
|
+
return inspect2(a) < inspect2(b) ? -1 : 1;
|
|
9369
|
+
}
|
|
9370
|
+
__name(compareByInspect, "compareByInspect");
|
|
9371
|
+
function getOwnEnumerablePropertySymbols(obj) {
|
|
9372
|
+
if ("function" != typeof Object.getOwnPropertySymbols) return [];
|
|
9373
|
+
return Object.getOwnPropertySymbols(obj).filter(function(sym) {
|
|
9374
|
+
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
|
9375
|
+
});
|
|
9376
|
+
}
|
|
9377
|
+
__name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
|
|
9378
|
+
function getOwnEnumerableProperties(obj) {
|
|
9379
|
+
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
9380
|
+
}
|
|
9381
|
+
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
9382
|
+
var isNaN2 = Number.isNaN;
|
|
9383
|
+
function isObjectType(obj) {
|
|
9384
|
+
let objectType = type(obj);
|
|
9385
|
+
let objectTypes = [
|
|
9386
|
+
"Array",
|
|
9387
|
+
"Object",
|
|
9388
|
+
"Function"
|
|
9389
|
+
];
|
|
9390
|
+
return -1 !== objectTypes.indexOf(objectType);
|
|
9391
|
+
}
|
|
9392
|
+
__name(isObjectType, "isObjectType");
|
|
9393
|
+
function getOperator(obj, args) {
|
|
9394
|
+
let operator = flag(obj, "operator");
|
|
9395
|
+
let negate = flag(obj, "negate");
|
|
9396
|
+
let expected = args[3];
|
|
9397
|
+
let msg = negate ? args[2] : args[1];
|
|
9398
|
+
if (operator) return operator;
|
|
9399
|
+
if ("function" == typeof msg) msg = msg();
|
|
9400
|
+
msg = msg || "";
|
|
9401
|
+
if (!msg) return;
|
|
9402
|
+
if (/\shave\s/.test(msg)) return;
|
|
9403
|
+
let isObject = isObjectType(expected);
|
|
9404
|
+
if (/\snot\s/.test(msg)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
9405
|
+
return isObject ? "deepStrictEqual" : "strictEqual";
|
|
9406
|
+
}
|
|
9407
|
+
__name(getOperator, "getOperator");
|
|
9408
|
+
function getName(fn) {
|
|
9409
|
+
return fn.name;
|
|
9410
|
+
}
|
|
9411
|
+
__name(getName, "getName");
|
|
9412
|
+
function isRegExp2(obj) {
|
|
9413
|
+
return "[object RegExp]" === Object.prototype.toString.call(obj);
|
|
9414
|
+
}
|
|
9415
|
+
__name(isRegExp2, "isRegExp");
|
|
9416
|
+
function isNumeric(obj) {
|
|
9417
|
+
return [
|
|
9418
|
+
"Number",
|
|
9419
|
+
"BigInt"
|
|
9420
|
+
].includes(type(obj));
|
|
9421
|
+
}
|
|
9422
|
+
__name(isNumeric, "isNumeric");
|
|
9423
|
+
var { flag: flag2 } = utils_exports;
|
|
9424
|
+
[
|
|
9425
|
+
"to",
|
|
9426
|
+
"be",
|
|
9427
|
+
"been",
|
|
9428
|
+
"is",
|
|
9429
|
+
"and",
|
|
9430
|
+
"has",
|
|
9431
|
+
"have",
|
|
9432
|
+
"with",
|
|
9433
|
+
"that",
|
|
9434
|
+
"which",
|
|
9435
|
+
"at",
|
|
9436
|
+
"of",
|
|
9437
|
+
"same",
|
|
9438
|
+
"but",
|
|
9439
|
+
"does",
|
|
9440
|
+
"still",
|
|
9441
|
+
"also"
|
|
9442
|
+
].forEach(function(chain) {
|
|
9443
|
+
Assertion.addProperty(chain);
|
|
9444
|
+
});
|
|
9445
|
+
Assertion.addProperty("not", function() {
|
|
9446
|
+
flag2(this, "negate", true);
|
|
9447
|
+
});
|
|
9448
|
+
Assertion.addProperty("deep", function() {
|
|
9449
|
+
flag2(this, "deep", true);
|
|
9450
|
+
});
|
|
9451
|
+
Assertion.addProperty("nested", function() {
|
|
9452
|
+
flag2(this, "nested", true);
|
|
9453
|
+
});
|
|
9454
|
+
Assertion.addProperty("own", function() {
|
|
9455
|
+
flag2(this, "own", true);
|
|
9456
|
+
});
|
|
9457
|
+
Assertion.addProperty("ordered", function() {
|
|
9458
|
+
flag2(this, "ordered", true);
|
|
9459
|
+
});
|
|
9460
|
+
Assertion.addProperty("any", function() {
|
|
9461
|
+
flag2(this, "any", true);
|
|
9462
|
+
flag2(this, "all", false);
|
|
9463
|
+
});
|
|
9464
|
+
Assertion.addProperty("all", function() {
|
|
9465
|
+
flag2(this, "all", true);
|
|
9466
|
+
flag2(this, "any", false);
|
|
9467
|
+
});
|
|
9468
|
+
var functionTypes = {
|
|
9469
|
+
function: [
|
|
9470
|
+
"function",
|
|
9471
|
+
"asyncfunction",
|
|
9472
|
+
"generatorfunction",
|
|
9473
|
+
"asyncgeneratorfunction"
|
|
9474
|
+
],
|
|
9475
|
+
asyncfunction: [
|
|
9476
|
+
"asyncfunction",
|
|
9477
|
+
"asyncgeneratorfunction"
|
|
9478
|
+
],
|
|
9479
|
+
generatorfunction: [
|
|
9480
|
+
"generatorfunction",
|
|
9481
|
+
"asyncgeneratorfunction"
|
|
9482
|
+
],
|
|
9483
|
+
asyncgeneratorfunction: [
|
|
9484
|
+
"asyncgeneratorfunction"
|
|
9485
|
+
]
|
|
9486
|
+
};
|
|
9487
|
+
function an(type3, msg) {
|
|
9488
|
+
if (msg) flag2(this, "message", msg);
|
|
9489
|
+
type3 = type3.toLowerCase();
|
|
9490
|
+
let obj = flag2(this, "object"), article = ~[
|
|
9491
|
+
"a",
|
|
9492
|
+
"e",
|
|
9493
|
+
"i",
|
|
9494
|
+
"o",
|
|
9495
|
+
"u"
|
|
9496
|
+
].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
9497
|
+
const detectedType = type(obj).toLowerCase();
|
|
9498
|
+
if (functionTypes["function"].includes(type3)) this.assert(functionTypes[type3].includes(detectedType), "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
9499
|
+
else this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
9500
|
+
}
|
|
9501
|
+
__name(an, "an");
|
|
9502
|
+
Assertion.addChainableMethod("an", an);
|
|
9503
|
+
Assertion.addChainableMethod("a", an);
|
|
9504
|
+
function SameValueZero(a, b) {
|
|
9505
|
+
return isNaN2(a) && isNaN2(b) || a === b;
|
|
9506
|
+
}
|
|
9507
|
+
__name(SameValueZero, "SameValueZero");
|
|
9508
|
+
function includeChainingBehavior() {
|
|
9509
|
+
flag2(this, "contains", true);
|
|
9510
|
+
}
|
|
9511
|
+
__name(includeChainingBehavior, "includeChainingBehavior");
|
|
9512
|
+
function include(val, msg) {
|
|
9513
|
+
if (msg) flag2(this, "message", msg);
|
|
9514
|
+
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;
|
|
9515
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
9516
|
+
let included = false;
|
|
9517
|
+
switch(objType){
|
|
9518
|
+
case "string":
|
|
9519
|
+
included = -1 !== obj.indexOf(val);
|
|
9520
|
+
break;
|
|
9521
|
+
case "weakset":
|
|
9522
|
+
if (isDeep) throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", void 0, ssfi);
|
|
9523
|
+
included = obj.has(val);
|
|
9524
|
+
break;
|
|
9525
|
+
case "map":
|
|
9526
|
+
obj.forEach(function(item) {
|
|
9527
|
+
included = included || isEql(item, val);
|
|
9528
|
+
});
|
|
9529
|
+
break;
|
|
9530
|
+
case "set":
|
|
9531
|
+
if (isDeep) obj.forEach(function(item) {
|
|
9532
|
+
included = included || isEql(item, val);
|
|
9533
|
+
});
|
|
9534
|
+
else included = obj.has(val);
|
|
9535
|
+
break;
|
|
9536
|
+
case "array":
|
|
9537
|
+
included = isDeep ? obj.some(function(item) {
|
|
9538
|
+
return isEql(item, val);
|
|
9539
|
+
}) : -1 !== obj.indexOf(val);
|
|
9540
|
+
break;
|
|
9541
|
+
default:
|
|
9542
|
+
{
|
|
9543
|
+
if (val !== Object(val)) throw new AssertionError(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(), void 0, ssfi);
|
|
9544
|
+
let props = Object.keys(val);
|
|
9545
|
+
let firstErr = null;
|
|
9546
|
+
let numErrs = 0;
|
|
9547
|
+
props.forEach(function(prop) {
|
|
9548
|
+
let propAssertion = new Assertion(obj);
|
|
9549
|
+
transferFlags(this, propAssertion, true);
|
|
9550
|
+
flag2(propAssertion, "lockSsfi", true);
|
|
9551
|
+
if (!negate || 1 === props.length) return void propAssertion.property(prop, val[prop]);
|
|
9552
|
+
try {
|
|
9553
|
+
propAssertion.property(prop, val[prop]);
|
|
9554
|
+
} catch (err) {
|
|
9555
|
+
if (!check_error_exports.compatibleConstructor(err, AssertionError)) throw err;
|
|
9556
|
+
if (null === firstErr) firstErr = err;
|
|
9557
|
+
numErrs++;
|
|
9558
|
+
}
|
|
9559
|
+
}, this);
|
|
9560
|
+
if (negate && props.length > 1 && numErrs === props.length) throw firstErr;
|
|
9561
|
+
return;
|
|
9562
|
+
}
|
|
9563
|
+
}
|
|
9564
|
+
this.assert(included, "expected #{this} to " + descriptor + "include " + inspect2(val), "expected #{this} to not " + descriptor + "include " + inspect2(val));
|
|
9565
|
+
}
|
|
9566
|
+
__name(include, "include");
|
|
9567
|
+
Assertion.addChainableMethod("include", include, includeChainingBehavior);
|
|
9568
|
+
Assertion.addChainableMethod("contain", include, includeChainingBehavior);
|
|
9569
|
+
Assertion.addChainableMethod("contains", include, includeChainingBehavior);
|
|
9570
|
+
Assertion.addChainableMethod("includes", include, includeChainingBehavior);
|
|
9571
|
+
Assertion.addProperty("ok", function() {
|
|
9572
|
+
this.assert(flag2(this, "object"), "expected #{this} to be truthy", "expected #{this} to be falsy");
|
|
9573
|
+
});
|
|
9574
|
+
Assertion.addProperty("true", function() {
|
|
9575
|
+
this.assert(true === flag2(this, "object"), "expected #{this} to be true", "expected #{this} to be false", !flag2(this, "negate"));
|
|
9576
|
+
});
|
|
9577
|
+
Assertion.addProperty("numeric", function() {
|
|
9578
|
+
const object = flag2(this, "object");
|
|
9579
|
+
this.assert([
|
|
9580
|
+
"Number",
|
|
9581
|
+
"BigInt"
|
|
9582
|
+
].includes(type(object)), "expected #{this} to be numeric", "expected #{this} to not be numeric", !flag2(this, "negate"));
|
|
9583
|
+
});
|
|
9584
|
+
Assertion.addProperty("callable", function() {
|
|
9585
|
+
const val = flag2(this, "object");
|
|
9586
|
+
const ssfi = flag2(this, "ssfi");
|
|
9587
|
+
const message = flag2(this, "message");
|
|
9588
|
+
const msg = message ? `${message}: ` : "";
|
|
9589
|
+
const negate = flag2(this, "negate");
|
|
9590
|
+
const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
|
|
9591
|
+
const isCallable = [
|
|
9592
|
+
"Function",
|
|
9593
|
+
"AsyncFunction",
|
|
9594
|
+
"GeneratorFunction",
|
|
9595
|
+
"AsyncGeneratorFunction"
|
|
9596
|
+
].includes(type(val));
|
|
9597
|
+
if (isCallable && negate || !isCallable && !negate) throw new AssertionError(assertionMessage, void 0, ssfi);
|
|
9598
|
+
});
|
|
9599
|
+
Assertion.addProperty("false", function() {
|
|
9600
|
+
this.assert(false === flag2(this, "object"), "expected #{this} to be false", "expected #{this} to be true", !!flag2(this, "negate"));
|
|
9601
|
+
});
|
|
9602
|
+
Assertion.addProperty("null", function() {
|
|
9603
|
+
this.assert(null === flag2(this, "object"), "expected #{this} to be null", "expected #{this} not to be null");
|
|
9604
|
+
});
|
|
9605
|
+
Assertion.addProperty("undefined", function() {
|
|
9606
|
+
this.assert(void 0 === flag2(this, "object"), "expected #{this} to be undefined", "expected #{this} not to be undefined");
|
|
9607
|
+
});
|
|
9608
|
+
Assertion.addProperty("NaN", function() {
|
|
9609
|
+
this.assert(isNaN2(flag2(this, "object")), "expected #{this} to be NaN", "expected #{this} not to be NaN");
|
|
9610
|
+
});
|
|
9611
|
+
function assertExist() {
|
|
9612
|
+
let val = flag2(this, "object");
|
|
9613
|
+
this.assert(null != val, "expected #{this} to exist", "expected #{this} to not exist");
|
|
9614
|
+
}
|
|
9615
|
+
__name(assertExist, "assertExist");
|
|
9616
|
+
Assertion.addProperty("exist", assertExist);
|
|
9617
|
+
Assertion.addProperty("exists", assertExist);
|
|
9618
|
+
Assertion.addProperty("empty", function() {
|
|
9619
|
+
let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
9620
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
9621
|
+
switch(type(val).toLowerCase()){
|
|
9622
|
+
case "array":
|
|
9623
|
+
case "string":
|
|
9624
|
+
itemsCount = val.length;
|
|
9625
|
+
break;
|
|
9626
|
+
case "map":
|
|
9627
|
+
case "set":
|
|
9628
|
+
itemsCount = val.size;
|
|
9629
|
+
break;
|
|
9630
|
+
case "weakmap":
|
|
9631
|
+
case "weakset":
|
|
9632
|
+
throw new AssertionError(flagMsg + ".empty was passed a weak collection", void 0, ssfi);
|
|
9633
|
+
case "function":
|
|
9634
|
+
{
|
|
9635
|
+
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
9636
|
+
throw new AssertionError(msg.trim(), void 0, ssfi);
|
|
9637
|
+
}
|
|
9638
|
+
default:
|
|
9639
|
+
if (val !== Object(val)) throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), void 0, ssfi);
|
|
9640
|
+
itemsCount = Object.keys(val).length;
|
|
9641
|
+
}
|
|
9642
|
+
this.assert(0 === itemsCount, "expected #{this} to be empty", "expected #{this} not to be empty");
|
|
9643
|
+
});
|
|
9644
|
+
function checkArguments() {
|
|
9645
|
+
let obj = flag2(this, "object"), type3 = type(obj);
|
|
9646
|
+
this.assert("Arguments" === type3, "expected #{this} to be arguments but got " + type3, "expected #{this} to not be arguments");
|
|
9647
|
+
}
|
|
9648
|
+
__name(checkArguments, "checkArguments");
|
|
9649
|
+
Assertion.addProperty("arguments", checkArguments);
|
|
9650
|
+
Assertion.addProperty("Arguments", checkArguments);
|
|
9651
|
+
function assertEqual(val, msg) {
|
|
9652
|
+
if (msg) flag2(this, "message", msg);
|
|
9653
|
+
let obj = flag2(this, "object");
|
|
9654
|
+
if (flag2(this, "deep")) {
|
|
9655
|
+
let prevLockSsfi = flag2(this, "lockSsfi");
|
|
9656
|
+
flag2(this, "lockSsfi", true);
|
|
9657
|
+
this.eql(val);
|
|
9658
|
+
flag2(this, "lockSsfi", prevLockSsfi);
|
|
9659
|
+
} else this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
|
|
9660
|
+
}
|
|
9661
|
+
__name(assertEqual, "assertEqual");
|
|
9662
|
+
Assertion.addMethod("equal", assertEqual);
|
|
9663
|
+
Assertion.addMethod("equals", assertEqual);
|
|
9664
|
+
Assertion.addMethod("eq", assertEqual);
|
|
9665
|
+
function assertEql(obj, msg) {
|
|
9666
|
+
if (msg) flag2(this, "message", msg);
|
|
9667
|
+
let eql = flag2(this, "eql");
|
|
9668
|
+
this.assert(eql(obj, flag2(this, "object")), "expected #{this} to deeply equal #{exp}", "expected #{this} to not deeply equal #{exp}", obj, this._obj, true);
|
|
9669
|
+
}
|
|
9670
|
+
__name(assertEql, "assertEql");
|
|
9671
|
+
Assertion.addMethod("eql", assertEql);
|
|
9672
|
+
Assertion.addMethod("eqls", assertEql);
|
|
9673
|
+
function assertAbove(n, msg) {
|
|
9674
|
+
if (msg) flag2(this, "message", msg);
|
|
9675
|
+
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();
|
|
9676
|
+
if (doLength && "map" !== objType && "set" !== objType) new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9677
|
+
if (doLength || "date" !== objType || "date" === nType) {
|
|
9678
|
+
if (!isNumeric(n) && (doLength || isNumeric(obj))) throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
|
|
9679
|
+
else if (!doLength && "date" !== objType && !isNumeric(obj)) {
|
|
9680
|
+
let printObj = "string" === objType ? "'" + obj + "'" : obj;
|
|
9681
|
+
throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
|
|
9682
|
+
}
|
|
9683
|
+
} else throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
|
|
9684
|
+
if (doLength) {
|
|
9685
|
+
let descriptor = "length", itemsCount;
|
|
9686
|
+
if ("map" === objType || "set" === objType) {
|
|
9687
|
+
descriptor = "size";
|
|
9688
|
+
itemsCount = obj.size;
|
|
9689
|
+
} else itemsCount = obj.length;
|
|
9690
|
+
this.assert(itemsCount > n, "expected #{this} to have a " + descriptor + " above #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " above #{exp}", n, itemsCount);
|
|
9691
|
+
} else this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
|
|
9692
|
+
}
|
|
9693
|
+
__name(assertAbove, "assertAbove");
|
|
9694
|
+
Assertion.addMethod("above", assertAbove);
|
|
9695
|
+
Assertion.addMethod("gt", assertAbove);
|
|
9696
|
+
Assertion.addMethod("greaterThan", assertAbove);
|
|
9697
|
+
function assertLeast(n, msg) {
|
|
9698
|
+
if (msg) flag2(this, "message", msg);
|
|
9699
|
+
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;
|
|
9700
|
+
if (doLength && "map" !== objType && "set" !== objType) new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9701
|
+
if (doLength || "date" !== objType || "date" === nType) if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to least must be a number";
|
|
9702
|
+
else if (doLength || "date" === objType || isNumeric(obj)) shouldThrow = false;
|
|
9703
|
+
else {
|
|
9704
|
+
let printObj = "string" === objType ? "'" + obj + "'" : obj;
|
|
9705
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
9706
|
+
}
|
|
9707
|
+
else errorMessage = msgPrefix + "the argument to least must be a date";
|
|
9708
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
9709
|
+
if (doLength) {
|
|
9710
|
+
let descriptor = "length", itemsCount;
|
|
9711
|
+
if ("map" === objType || "set" === objType) {
|
|
9712
|
+
descriptor = "size";
|
|
9713
|
+
itemsCount = obj.size;
|
|
9714
|
+
} else itemsCount = obj.length;
|
|
9715
|
+
this.assert(itemsCount >= n, "expected #{this} to have a " + descriptor + " at least #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " below #{exp}", n, itemsCount);
|
|
9716
|
+
} else this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
|
|
9717
|
+
}
|
|
9718
|
+
__name(assertLeast, "assertLeast");
|
|
9719
|
+
Assertion.addMethod("least", assertLeast);
|
|
9720
|
+
Assertion.addMethod("gte", assertLeast);
|
|
9721
|
+
Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
9722
|
+
function assertBelow(n, msg) {
|
|
9723
|
+
if (msg) flag2(this, "message", msg);
|
|
9724
|
+
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;
|
|
9725
|
+
if (doLength && "map" !== objType && "set" !== objType) new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9726
|
+
if (doLength || "date" !== objType || "date" === nType) if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to below must be a number";
|
|
9727
|
+
else if (doLength || "date" === objType || isNumeric(obj)) shouldThrow = false;
|
|
9728
|
+
else {
|
|
9729
|
+
let printObj = "string" === objType ? "'" + obj + "'" : obj;
|
|
9730
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
9731
|
+
}
|
|
9732
|
+
else errorMessage = msgPrefix + "the argument to below must be a date";
|
|
9733
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
9734
|
+
if (doLength) {
|
|
9735
|
+
let descriptor = "length", itemsCount;
|
|
9736
|
+
if ("map" === objType || "set" === objType) {
|
|
9737
|
+
descriptor = "size";
|
|
9738
|
+
itemsCount = obj.size;
|
|
9739
|
+
} else itemsCount = obj.length;
|
|
9740
|
+
this.assert(itemsCount < n, "expected #{this} to have a " + descriptor + " below #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " below #{exp}", n, itemsCount);
|
|
9741
|
+
} else this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
|
|
9742
|
+
}
|
|
9743
|
+
__name(assertBelow, "assertBelow");
|
|
9744
|
+
Assertion.addMethod("below", assertBelow);
|
|
9745
|
+
Assertion.addMethod("lt", assertBelow);
|
|
9746
|
+
Assertion.addMethod("lessThan", assertBelow);
|
|
9747
|
+
function assertMost(n, msg) {
|
|
9748
|
+
if (msg) flag2(this, "message", msg);
|
|
9749
|
+
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;
|
|
9750
|
+
if (doLength && "map" !== objType && "set" !== objType) new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9751
|
+
if (doLength || "date" !== objType || "date" === nType) if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to most must be a number";
|
|
9752
|
+
else if (doLength || "date" === objType || isNumeric(obj)) shouldThrow = false;
|
|
9753
|
+
else {
|
|
9754
|
+
let printObj = "string" === objType ? "'" + obj + "'" : obj;
|
|
9755
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
9756
|
+
}
|
|
9757
|
+
else errorMessage = msgPrefix + "the argument to most must be a date";
|
|
9758
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
9759
|
+
if (doLength) {
|
|
9760
|
+
let descriptor = "length", itemsCount;
|
|
9761
|
+
if ("map" === objType || "set" === objType) {
|
|
9762
|
+
descriptor = "size";
|
|
9763
|
+
itemsCount = obj.size;
|
|
9764
|
+
} else itemsCount = obj.length;
|
|
9765
|
+
this.assert(itemsCount <= n, "expected #{this} to have a " + descriptor + " at most #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " above #{exp}", n, itemsCount);
|
|
9766
|
+
} else this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
|
|
9767
|
+
}
|
|
9768
|
+
__name(assertMost, "assertMost");
|
|
9769
|
+
Assertion.addMethod("most", assertMost);
|
|
9770
|
+
Assertion.addMethod("lte", assertMost);
|
|
9771
|
+
Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
9772
|
+
Assertion.addMethod("within", function(start, finish, msg) {
|
|
9773
|
+
if (msg) flag2(this, "message", msg);
|
|
9774
|
+
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 = "date" === startType && "date" === finishType ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
9775
|
+
if (doLength && "map" !== objType && "set" !== objType) new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9776
|
+
if (doLength || "date" !== objType || "date" === startType && "date" === finishType) if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
9777
|
+
else if (doLength || "date" === objType || isNumeric(obj)) shouldThrow = false;
|
|
9778
|
+
else {
|
|
9779
|
+
let printObj = "string" === objType ? "'" + obj + "'" : obj;
|
|
9780
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
9781
|
+
}
|
|
9782
|
+
else errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
9783
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
9784
|
+
if (doLength) {
|
|
9785
|
+
let descriptor = "length", itemsCount;
|
|
9786
|
+
if ("map" === objType || "set" === objType) {
|
|
9787
|
+
descriptor = "size";
|
|
9788
|
+
itemsCount = obj.size;
|
|
9789
|
+
} else itemsCount = obj.length;
|
|
9790
|
+
this.assert(itemsCount >= start && itemsCount <= finish, "expected #{this} to have a " + descriptor + " within " + range, "expected #{this} to not have a " + descriptor + " within " + range);
|
|
9791
|
+
} else this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
|
|
9792
|
+
});
|
|
9793
|
+
function assertInstanceOf(constructor, msg) {
|
|
9794
|
+
if (msg) flag2(this, "message", msg);
|
|
9795
|
+
let target = flag2(this, "object");
|
|
9796
|
+
let ssfi = flag2(this, "ssfi");
|
|
9797
|
+
let flagMsg = flag2(this, "message");
|
|
9798
|
+
let isInstanceOf;
|
|
9799
|
+
try {
|
|
9800
|
+
isInstanceOf = target instanceof constructor;
|
|
9801
|
+
} catch (err) {
|
|
9802
|
+
if (err instanceof TypeError) {
|
|
9803
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
9804
|
+
throw new AssertionError(flagMsg + "The instanceof assertion needs a constructor but " + type(constructor) + " was given.", void 0, ssfi);
|
|
9805
|
+
}
|
|
9806
|
+
throw err;
|
|
9807
|
+
}
|
|
9808
|
+
let name = getName(constructor);
|
|
9809
|
+
if (null == name) name = "an unnamed constructor";
|
|
9810
|
+
this.assert(isInstanceOf, "expected #{this} to be an instance of " + name, "expected #{this} to not be an instance of " + name);
|
|
9811
|
+
}
|
|
9812
|
+
__name(assertInstanceOf, "assertInstanceOf");
|
|
9813
|
+
Assertion.addMethod("instanceof", assertInstanceOf);
|
|
9814
|
+
Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
9815
|
+
function assertProperty(name, val, msg) {
|
|
9816
|
+
if (msg) flag2(this, "message", msg);
|
|
9817
|
+
let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
9818
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
9819
|
+
if (isNested) {
|
|
9820
|
+
if ("string" !== nameType) throw new AssertionError(flagMsg + "the argument to property must be a string when using nested syntax", void 0, ssfi);
|
|
9821
|
+
} else if ("string" !== nameType && "number" !== nameType && "symbol" !== nameType) throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", void 0, ssfi);
|
|
9822
|
+
if (isNested && isOwn) throw new AssertionError(flagMsg + 'The "nested" and "own" flags cannot be combined.', void 0, ssfi);
|
|
9823
|
+
if (null == obj) throw new AssertionError(flagMsg + "Target cannot be null or undefined.", void 0, ssfi);
|
|
9824
|
+
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;
|
|
9825
|
+
let descriptor = "";
|
|
9826
|
+
if (isDeep) descriptor += "deep ";
|
|
9827
|
+
if (isOwn) descriptor += "own ";
|
|
9828
|
+
if (isNested) descriptor += "nested ";
|
|
9829
|
+
descriptor += "property ";
|
|
9830
|
+
let hasProperty2;
|
|
9831
|
+
hasProperty2 = isOwn ? Object.prototype.hasOwnProperty.call(obj, name) : isNested ? pathInfo.exists : hasProperty(obj, name);
|
|
9832
|
+
if (!negate || 1 === arguments.length) this.assert(hasProperty2, "expected #{this} to have " + descriptor + inspect2(name), "expected #{this} to not have " + descriptor + inspect2(name));
|
|
9833
|
+
if (arguments.length > 1) this.assert(hasProperty2 && isEql(val, value), "expected #{this} to have " + descriptor + inspect2(name) + " of #{exp}, but got #{act}", "expected #{this} to not have " + descriptor + inspect2(name) + " of #{act}", val, value);
|
|
9834
|
+
flag2(this, "object", value);
|
|
9835
|
+
}
|
|
9836
|
+
__name(assertProperty, "assertProperty");
|
|
9837
|
+
Assertion.addMethod("property", assertProperty);
|
|
9838
|
+
function assertOwnProperty(_name, _value, _msg) {
|
|
9839
|
+
flag2(this, "own", true);
|
|
9840
|
+
assertProperty.apply(this, arguments);
|
|
9841
|
+
}
|
|
9842
|
+
__name(assertOwnProperty, "assertOwnProperty");
|
|
9843
|
+
Assertion.addMethod("ownProperty", assertOwnProperty);
|
|
9844
|
+
Assertion.addMethod("haveOwnProperty", assertOwnProperty);
|
|
9845
|
+
function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
9846
|
+
if ("string" == typeof descriptor) {
|
|
9847
|
+
msg = descriptor;
|
|
9848
|
+
descriptor = null;
|
|
9849
|
+
}
|
|
9850
|
+
if (msg) flag2(this, "message", msg);
|
|
9851
|
+
let obj = flag2(this, "object");
|
|
9852
|
+
let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
9853
|
+
let eql = flag2(this, "eql");
|
|
9854
|
+
if (actualDescriptor && descriptor) this.assert(eql(descriptor, actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to match " + inspect2(descriptor) + ", got " + inspect2(actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to not match " + inspect2(descriptor), descriptor, actualDescriptor, true);
|
|
9855
|
+
else this.assert(actualDescriptor, "expected #{this} to have an own property descriptor for " + inspect2(name), "expected #{this} to not have an own property descriptor for " + inspect2(name));
|
|
9856
|
+
flag2(this, "object", actualDescriptor);
|
|
9857
|
+
}
|
|
9858
|
+
__name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
|
|
9859
|
+
Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
9860
|
+
Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
9861
|
+
function assertLengthChain() {
|
|
9862
|
+
flag2(this, "doLength", true);
|
|
9863
|
+
}
|
|
9864
|
+
__name(assertLengthChain, "assertLengthChain");
|
|
9865
|
+
function assertLength(n, msg) {
|
|
9866
|
+
if (msg) flag2(this, "message", msg);
|
|
9867
|
+
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
9868
|
+
switch(objType){
|
|
9869
|
+
case "map":
|
|
9870
|
+
case "set":
|
|
9871
|
+
descriptor = "size";
|
|
9872
|
+
itemsCount = obj.size;
|
|
9873
|
+
break;
|
|
9874
|
+
default:
|
|
9875
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
9876
|
+
itemsCount = obj.length;
|
|
9877
|
+
}
|
|
9878
|
+
this.assert(itemsCount == n, "expected #{this} to have a " + descriptor + " of #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " of #{act}", n, itemsCount);
|
|
9879
|
+
}
|
|
9880
|
+
__name(assertLength, "assertLength");
|
|
9881
|
+
Assertion.addChainableMethod("length", assertLength, assertLengthChain);
|
|
9882
|
+
Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
9883
|
+
function assertMatch(re, msg) {
|
|
9884
|
+
if (msg) flag2(this, "message", msg);
|
|
9885
|
+
let obj = flag2(this, "object");
|
|
9886
|
+
this.assert(re.exec(obj), "expected #{this} to match " + re, "expected #{this} not to match " + re);
|
|
9887
|
+
}
|
|
9888
|
+
__name(assertMatch, "assertMatch");
|
|
9889
|
+
Assertion.addMethod("match", assertMatch);
|
|
9890
|
+
Assertion.addMethod("matches", assertMatch);
|
|
9891
|
+
Assertion.addMethod("string", function(str, msg) {
|
|
9892
|
+
if (msg) flag2(this, "message", msg);
|
|
9893
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
9894
|
+
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
9895
|
+
this.assert(~obj.indexOf(str), "expected #{this} to contain " + inspect2(str), "expected #{this} to not contain " + inspect2(str));
|
|
9896
|
+
});
|
|
9897
|
+
function assertKeys(keys) {
|
|
9898
|
+
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");
|
|
9899
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
9900
|
+
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";
|
|
9901
|
+
if ("Map" === objType || "Set" === objType) {
|
|
9902
|
+
deepStr = isDeep ? "deeply " : "";
|
|
9903
|
+
actual = [];
|
|
9904
|
+
obj.forEach(function(val, key) {
|
|
9905
|
+
actual.push(key);
|
|
9906
|
+
});
|
|
9907
|
+
if ("Array" !== keysType) keys = Array.prototype.slice.call(arguments);
|
|
9908
|
+
} else {
|
|
9909
|
+
actual = getOwnEnumerableProperties(obj);
|
|
9910
|
+
switch(keysType){
|
|
9911
|
+
case "Array":
|
|
9912
|
+
if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
9913
|
+
break;
|
|
9914
|
+
case "Object":
|
|
9915
|
+
if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
9916
|
+
keys = Object.keys(keys);
|
|
9917
|
+
break;
|
|
9918
|
+
default:
|
|
9919
|
+
keys = Array.prototype.slice.call(arguments);
|
|
9920
|
+
}
|
|
9921
|
+
keys = keys.map(function(val) {
|
|
9922
|
+
return "symbol" == typeof val ? val : String(val);
|
|
9923
|
+
});
|
|
9924
|
+
}
|
|
9925
|
+
if (!keys.length) throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
9926
|
+
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2)=>val1 === val2;
|
|
9927
|
+
if (!any && !all) all = true;
|
|
9928
|
+
if (any) ok = expected.some(function(expectedKey) {
|
|
9929
|
+
return actual.some(function(actualKey) {
|
|
9930
|
+
return isEql(expectedKey, actualKey);
|
|
9931
|
+
});
|
|
9932
|
+
});
|
|
9933
|
+
if (all) {
|
|
9934
|
+
ok = expected.every(function(expectedKey) {
|
|
9935
|
+
return actual.some(function(actualKey) {
|
|
9936
|
+
return isEql(expectedKey, actualKey);
|
|
9937
|
+
});
|
|
9938
|
+
});
|
|
9939
|
+
if (!flag2(this, "contains")) ok = ok && keys.length == actual.length;
|
|
9940
|
+
}
|
|
9941
|
+
if (len > 1) {
|
|
9942
|
+
keys = keys.map(function(key) {
|
|
9943
|
+
return inspect2(key);
|
|
9944
|
+
});
|
|
9945
|
+
let last = keys.pop();
|
|
9946
|
+
if (all) str = keys.join(", ") + ", and " + last;
|
|
9947
|
+
if (any) str = keys.join(", ") + ", or " + last;
|
|
9948
|
+
} else str = inspect2(keys[0]);
|
|
9949
|
+
str = (len > 1 ? "keys " : "key ") + str;
|
|
9950
|
+
str = (flag2(this, "contains") ? "contain " : "have ") + str;
|
|
9951
|
+
this.assert(ok, "expected #{this} to " + deepStr + str, "expected #{this} to not " + deepStr + str, expected.slice(0).sort(compareByInspect), actual.sort(compareByInspect), true);
|
|
9952
|
+
}
|
|
9953
|
+
__name(assertKeys, "assertKeys");
|
|
9954
|
+
Assertion.addMethod("keys", assertKeys);
|
|
9955
|
+
Assertion.addMethod("key", assertKeys);
|
|
9956
|
+
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
9957
|
+
if (msg) flag2(this, "message", msg);
|
|
9958
|
+
let obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
9959
|
+
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
9960
|
+
if (isRegExp2(errorLike) || "string" == typeof errorLike) {
|
|
9961
|
+
errMsgMatcher = errorLike;
|
|
9962
|
+
errorLike = null;
|
|
9963
|
+
}
|
|
9964
|
+
let caughtErr;
|
|
9965
|
+
let errorWasThrown = false;
|
|
9966
|
+
try {
|
|
9967
|
+
obj();
|
|
9968
|
+
} catch (err) {
|
|
9969
|
+
errorWasThrown = true;
|
|
9970
|
+
caughtErr = err;
|
|
9971
|
+
}
|
|
9972
|
+
let everyArgIsUndefined = void 0 === errorLike && void 0 === errMsgMatcher;
|
|
9973
|
+
let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
9974
|
+
let errorLikeFail = false;
|
|
9975
|
+
let errMsgMatcherFail = false;
|
|
9976
|
+
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
9977
|
+
let errorLikeString = "an error";
|
|
9978
|
+
if (errorLike instanceof Error) errorLikeString = "#{exp}";
|
|
9979
|
+
else if (errorLike) errorLikeString = check_error_exports.getConstructorName(errorLike);
|
|
9980
|
+
let actual = caughtErr;
|
|
9981
|
+
if (caughtErr instanceof Error) actual = caughtErr.toString();
|
|
9982
|
+
else if ("string" == typeof caughtErr) actual = caughtErr;
|
|
9983
|
+
else if (caughtErr && ("object" == typeof caughtErr || "function" == typeof caughtErr)) try {
|
|
9984
|
+
actual = check_error_exports.getConstructorName(caughtErr);
|
|
9985
|
+
} catch (_err) {}
|
|
9986
|
+
this.assert(errorWasThrown, "expected #{this} to throw " + errorLikeString, "expected #{this} to not throw an error but #{act} was thrown", errorLike && errorLike.toString(), actual);
|
|
9987
|
+
}
|
|
9988
|
+
if (errorLike && caughtErr) {
|
|
9989
|
+
if (errorLike instanceof Error) {
|
|
9990
|
+
let isCompatibleInstance = check_error_exports.compatibleInstance(caughtErr, errorLike);
|
|
9991
|
+
if (isCompatibleInstance === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
|
|
9992
|
+
else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr && !negate ? " but #{act} was thrown" : ""), errorLike.toString(), caughtErr.toString());
|
|
9993
|
+
}
|
|
9994
|
+
let isCompatibleConstructor = check_error_exports.compatibleConstructor(caughtErr, errorLike);
|
|
9995
|
+
if (isCompatibleConstructor === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
|
|
9996
|
+
else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
|
|
9997
|
+
}
|
|
9998
|
+
if (caughtErr && null != errMsgMatcher) {
|
|
9999
|
+
let placeholder = "including";
|
|
10000
|
+
if (isRegExp2(errMsgMatcher)) placeholder = "matching";
|
|
10001
|
+
let isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
|
|
10002
|
+
if (isCompatibleMessage === negate) if (everyArgIsDefined && negate) errMsgMatcherFail = true;
|
|
10003
|
+
else this.assert(negate, "expected #{this} to throw error " + placeholder + " #{exp} but got #{act}", "expected #{this} to throw error not " + placeholder + " #{exp}", errMsgMatcher, check_error_exports.getMessage(caughtErr));
|
|
10004
|
+
}
|
|
10005
|
+
if (errorLikeFail && errMsgMatcherFail) this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
|
|
10006
|
+
flag2(this, "object", caughtErr);
|
|
10007
|
+
}
|
|
10008
|
+
__name(assertThrows, "assertThrows");
|
|
10009
|
+
Assertion.addMethod("throw", assertThrows);
|
|
10010
|
+
Assertion.addMethod("throws", assertThrows);
|
|
10011
|
+
Assertion.addMethod("Throw", assertThrows);
|
|
10012
|
+
function respondTo(method, msg) {
|
|
10013
|
+
if (msg) flag2(this, "message", msg);
|
|
10014
|
+
let obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" != typeof obj || itself ? obj[method] : obj.prototype[method];
|
|
10015
|
+
this.assert("function" == typeof context, "expected #{this} to respond to " + inspect2(method), "expected #{this} to not respond to " + inspect2(method));
|
|
10016
|
+
}
|
|
10017
|
+
__name(respondTo, "respondTo");
|
|
10018
|
+
Assertion.addMethod("respondTo", respondTo);
|
|
10019
|
+
Assertion.addMethod("respondsTo", respondTo);
|
|
10020
|
+
Assertion.addProperty("itself", function() {
|
|
10021
|
+
flag2(this, "itself", true);
|
|
10022
|
+
});
|
|
10023
|
+
function satisfy(matcher, msg) {
|
|
10024
|
+
if (msg) flag2(this, "message", msg);
|
|
10025
|
+
let obj = flag2(this, "object");
|
|
10026
|
+
let result = matcher(obj);
|
|
10027
|
+
this.assert(result, "expected #{this} to satisfy " + objDisplay(matcher), "expected #{this} to not satisfy" + objDisplay(matcher), !flag2(this, "negate"), result);
|
|
10028
|
+
}
|
|
10029
|
+
__name(satisfy, "satisfy");
|
|
10030
|
+
Assertion.addMethod("satisfy", satisfy);
|
|
10031
|
+
Assertion.addMethod("satisfies", satisfy);
|
|
10032
|
+
function closeTo(expected, delta, msg) {
|
|
10033
|
+
if (msg) flag2(this, "message", msg);
|
|
10034
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
10035
|
+
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
10036
|
+
let message = "A `delta` value is required for `closeTo`";
|
|
10037
|
+
if (void 0 == delta) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
10038
|
+
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
10039
|
+
message = "A `expected` value is required for `closeTo`";
|
|
10040
|
+
if (void 0 == expected) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
10041
|
+
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
10042
|
+
const abs = /* @__PURE__ */ __name((x)=>x < 0n ? -x : x, "abs");
|
|
10043
|
+
const strip = /* @__PURE__ */ __name((number)=>parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
10044
|
+
this.assert(strip(abs(obj - expected)) <= delta, "expected #{this} to be close to " + expected + " +/- " + delta, "expected #{this} not to be close to " + expected + " +/- " + delta);
|
|
10045
|
+
}
|
|
10046
|
+
__name(closeTo, "closeTo");
|
|
10047
|
+
Assertion.addMethod("closeTo", closeTo);
|
|
10048
|
+
Assertion.addMethod("approximately", closeTo);
|
|
10049
|
+
function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
|
|
10050
|
+
let superset = Array.from(_superset);
|
|
10051
|
+
let subset = Array.from(_subset);
|
|
10052
|
+
if (!contains) {
|
|
10053
|
+
if (subset.length !== superset.length) return false;
|
|
10054
|
+
superset = superset.slice();
|
|
10055
|
+
}
|
|
10056
|
+
return subset.every(function(elem, idx) {
|
|
10057
|
+
if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
10058
|
+
if (!cmp) {
|
|
10059
|
+
let matchIdx = superset.indexOf(elem);
|
|
10060
|
+
if (-1 === matchIdx) return false;
|
|
10061
|
+
if (!contains) superset.splice(matchIdx, 1);
|
|
10062
|
+
return true;
|
|
10063
|
+
}
|
|
10064
|
+
return superset.some(function(elem2, matchIdx) {
|
|
10065
|
+
if (!cmp(elem, elem2)) return false;
|
|
10066
|
+
if (!contains) superset.splice(matchIdx, 1);
|
|
10067
|
+
return true;
|
|
10068
|
+
});
|
|
10069
|
+
});
|
|
10070
|
+
}
|
|
10071
|
+
__name(isSubsetOf, "isSubsetOf");
|
|
10072
|
+
Assertion.addMethod("members", function(subset, msg) {
|
|
10073
|
+
if (msg) flag2(this, "message", msg);
|
|
10074
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
10075
|
+
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
|
|
10076
|
+
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
|
|
10077
|
+
let contains = flag2(this, "contains");
|
|
10078
|
+
let ordered = flag2(this, "ordered");
|
|
10079
|
+
let subject, failMsg, failNegateMsg;
|
|
10080
|
+
if (contains) {
|
|
10081
|
+
subject = ordered ? "an ordered superset" : "a superset";
|
|
10082
|
+
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
10083
|
+
failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
|
|
10084
|
+
} else {
|
|
10085
|
+
subject = ordered ? "ordered members" : "members";
|
|
10086
|
+
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
10087
|
+
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
10088
|
+
}
|
|
10089
|
+
let cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
|
|
10090
|
+
this.assert(isSubsetOf(subset, obj, cmp, contains, ordered), failMsg, failNegateMsg, subset, obj, true);
|
|
10091
|
+
});
|
|
10092
|
+
Assertion.addProperty("iterable", function(msg) {
|
|
10093
|
+
if (msg) flag2(this, "message", msg);
|
|
10094
|
+
let obj = flag2(this, "object");
|
|
10095
|
+
this.assert(void 0 != obj && obj[Symbol.iterator], "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
|
|
10096
|
+
});
|
|
10097
|
+
function oneOf(list, msg) {
|
|
10098
|
+
if (msg) flag2(this, "message", msg);
|
|
10099
|
+
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");
|
|
10100
|
+
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
10101
|
+
if (contains) this.assert(list.some(function(possibility) {
|
|
10102
|
+
return expected.indexOf(possibility) > -1;
|
|
10103
|
+
}), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
|
|
10104
|
+
else if (isDeep) this.assert(list.some(function(possibility) {
|
|
10105
|
+
return eql(expected, possibility);
|
|
10106
|
+
}), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
|
|
10107
|
+
else this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
|
|
10108
|
+
}
|
|
10109
|
+
__name(oneOf, "oneOf");
|
|
10110
|
+
Assertion.addMethod("oneOf", oneOf);
|
|
10111
|
+
function assertChanges(subject, prop, msg) {
|
|
10112
|
+
if (msg) flag2(this, "message", msg);
|
|
10113
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
10114
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
10115
|
+
let initial;
|
|
10116
|
+
if (prop) {
|
|
10117
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
10118
|
+
initial = subject[prop];
|
|
10119
|
+
} else {
|
|
10120
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
10121
|
+
initial = subject();
|
|
10122
|
+
}
|
|
10123
|
+
fn();
|
|
10124
|
+
let final = null == prop ? subject() : subject[prop];
|
|
10125
|
+
let msgObj = null == prop ? initial : "." + prop;
|
|
10126
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
10127
|
+
flag2(this, "initialDeltaValue", initial);
|
|
10128
|
+
flag2(this, "finalDeltaValue", final);
|
|
10129
|
+
flag2(this, "deltaBehavior", "change");
|
|
10130
|
+
flag2(this, "realDelta", final !== initial);
|
|
10131
|
+
this.assert(initial !== final, "expected " + msgObj + " to change", "expected " + msgObj + " to not change");
|
|
10132
|
+
}
|
|
10133
|
+
__name(assertChanges, "assertChanges");
|
|
10134
|
+
Assertion.addMethod("change", assertChanges);
|
|
10135
|
+
Assertion.addMethod("changes", assertChanges);
|
|
10136
|
+
function assertIncreases(subject, prop, msg) {
|
|
10137
|
+
if (msg) flag2(this, "message", msg);
|
|
10138
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
10139
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
10140
|
+
let initial;
|
|
10141
|
+
if (prop) {
|
|
10142
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
10143
|
+
initial = subject[prop];
|
|
10144
|
+
} else {
|
|
10145
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
10146
|
+
initial = subject();
|
|
10147
|
+
}
|
|
10148
|
+
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
10149
|
+
fn();
|
|
10150
|
+
let final = null == prop ? subject() : subject[prop];
|
|
10151
|
+
let msgObj = null == prop ? initial : "." + prop;
|
|
10152
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
10153
|
+
flag2(this, "initialDeltaValue", initial);
|
|
10154
|
+
flag2(this, "finalDeltaValue", final);
|
|
10155
|
+
flag2(this, "deltaBehavior", "increase");
|
|
10156
|
+
flag2(this, "realDelta", final - initial);
|
|
10157
|
+
this.assert(final - initial > 0, "expected " + msgObj + " to increase", "expected " + msgObj + " to not increase");
|
|
10158
|
+
}
|
|
10159
|
+
__name(assertIncreases, "assertIncreases");
|
|
10160
|
+
Assertion.addMethod("increase", assertIncreases);
|
|
10161
|
+
Assertion.addMethod("increases", assertIncreases);
|
|
10162
|
+
function assertDecreases(subject, prop, msg) {
|
|
10163
|
+
if (msg) flag2(this, "message", msg);
|
|
10164
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
10165
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
10166
|
+
let initial;
|
|
10167
|
+
if (prop) {
|
|
10168
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
10169
|
+
initial = subject[prop];
|
|
10170
|
+
} else {
|
|
10171
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
10172
|
+
initial = subject();
|
|
10173
|
+
}
|
|
10174
|
+
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
10175
|
+
fn();
|
|
10176
|
+
let final = null == prop ? subject() : subject[prop];
|
|
10177
|
+
let msgObj = null == prop ? initial : "." + prop;
|
|
10178
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
10179
|
+
flag2(this, "initialDeltaValue", initial);
|
|
10180
|
+
flag2(this, "finalDeltaValue", final);
|
|
10181
|
+
flag2(this, "deltaBehavior", "decrease");
|
|
10182
|
+
flag2(this, "realDelta", initial - final);
|
|
10183
|
+
this.assert(final - initial < 0, "expected " + msgObj + " to decrease", "expected " + msgObj + " to not decrease");
|
|
10184
|
+
}
|
|
10185
|
+
__name(assertDecreases, "assertDecreases");
|
|
10186
|
+
Assertion.addMethod("decrease", assertDecreases);
|
|
10187
|
+
Assertion.addMethod("decreases", assertDecreases);
|
|
10188
|
+
function assertDelta(delta, msg) {
|
|
10189
|
+
if (msg) flag2(this, "message", msg);
|
|
10190
|
+
let msgObj = flag2(this, "deltaMsgObj");
|
|
10191
|
+
let initial = flag2(this, "initialDeltaValue");
|
|
10192
|
+
let final = flag2(this, "finalDeltaValue");
|
|
10193
|
+
let behavior = flag2(this, "deltaBehavior");
|
|
10194
|
+
let realDelta = flag2(this, "realDelta");
|
|
10195
|
+
let expression;
|
|
10196
|
+
expression = "change" === behavior ? Math.abs(final - initial) === Math.abs(delta) : realDelta === Math.abs(delta);
|
|
10197
|
+
this.assert(expression, "expected " + msgObj + " to " + behavior + " by " + delta, "expected " + msgObj + " to not " + behavior + " by " + delta);
|
|
10198
|
+
}
|
|
10199
|
+
__name(assertDelta, "assertDelta");
|
|
10200
|
+
Assertion.addMethod("by", assertDelta);
|
|
10201
|
+
Assertion.addProperty("extensible", function() {
|
|
10202
|
+
let obj = flag2(this, "object");
|
|
10203
|
+
let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
10204
|
+
this.assert(isExtensible, "expected #{this} to be extensible", "expected #{this} to not be extensible");
|
|
10205
|
+
});
|
|
10206
|
+
Assertion.addProperty("sealed", function() {
|
|
10207
|
+
let obj = flag2(this, "object");
|
|
10208
|
+
let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
10209
|
+
this.assert(isSealed, "expected #{this} to be sealed", "expected #{this} to not be sealed");
|
|
10210
|
+
});
|
|
10211
|
+
Assertion.addProperty("frozen", function() {
|
|
10212
|
+
let obj = flag2(this, "object");
|
|
10213
|
+
let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
10214
|
+
this.assert(isFrozen, "expected #{this} to be frozen", "expected #{this} to not be frozen");
|
|
10215
|
+
});
|
|
10216
|
+
Assertion.addProperty("finite", function(_msg) {
|
|
10217
|
+
let obj = flag2(this, "object");
|
|
10218
|
+
this.assert("number" == typeof obj && isFinite(obj), "expected #{this} to be a finite number", "expected #{this} to not be a finite number");
|
|
10219
|
+
});
|
|
10220
|
+
function compareSubset(expected, actual) {
|
|
10221
|
+
if (expected === actual) return true;
|
|
10222
|
+
if (typeof actual !== typeof expected) return false;
|
|
10223
|
+
if ("object" != typeof expected || null === expected) return expected === actual;
|
|
10224
|
+
if (!actual) return false;
|
|
10225
|
+
if (Array.isArray(expected)) {
|
|
10226
|
+
if (!Array.isArray(actual)) return false;
|
|
10227
|
+
return expected.every(function(exp) {
|
|
10228
|
+
return actual.some(function(act) {
|
|
10229
|
+
return compareSubset(exp, act);
|
|
10230
|
+
});
|
|
10231
|
+
});
|
|
10232
|
+
}
|
|
10233
|
+
if (expected instanceof Date) if (actual instanceof Date) return expected.getTime() === actual.getTime();
|
|
10234
|
+
else return false;
|
|
10235
|
+
return Object.keys(expected).every(function(key) {
|
|
10236
|
+
let expectedValue = expected[key];
|
|
10237
|
+
let actualValue = actual[key];
|
|
10238
|
+
if ("object" == typeof expectedValue && null !== expectedValue && null !== actualValue) return compareSubset(expectedValue, actualValue);
|
|
10239
|
+
if ("function" == typeof expectedValue) return expectedValue(actualValue);
|
|
10240
|
+
return actualValue === expectedValue;
|
|
10241
|
+
});
|
|
10242
|
+
}
|
|
10243
|
+
__name(compareSubset, "compareSubset");
|
|
10244
|
+
Assertion.addMethod("containSubset", function(expected) {
|
|
10245
|
+
const actual = flag(this, "object");
|
|
10246
|
+
const showDiff = config.showDiff;
|
|
10247
|
+
this.assert(compareSubset(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
|
|
10248
|
+
});
|
|
10249
|
+
function expect(val, message) {
|
|
10250
|
+
return new Assertion(val, message);
|
|
10251
|
+
}
|
|
10252
|
+
__name(expect, "expect");
|
|
10253
|
+
expect.fail = function(actual, expected, message, operator) {
|
|
10254
|
+
if (arguments.length < 2) {
|
|
10255
|
+
message = actual;
|
|
10256
|
+
actual = void 0;
|
|
10257
|
+
}
|
|
10258
|
+
message = message || "expect.fail()";
|
|
10259
|
+
throw new AssertionError(message, {
|
|
10260
|
+
actual,
|
|
10261
|
+
expected,
|
|
10262
|
+
operator
|
|
10263
|
+
}, expect.fail);
|
|
10264
|
+
};
|
|
10265
|
+
var should_exports = {};
|
|
10266
|
+
__export(should_exports, {
|
|
10267
|
+
Should: ()=>Should,
|
|
10268
|
+
should: ()=>should
|
|
10269
|
+
});
|
|
10270
|
+
function loadShould() {
|
|
10271
|
+
function shouldGetter() {
|
|
10272
|
+
if (this instanceof String || this instanceof Number || this instanceof Boolean || "function" == typeof Symbol && this instanceof Symbol || "function" == typeof BigInt && this instanceof BigInt) return new Assertion(this.valueOf(), null, shouldGetter);
|
|
10273
|
+
return new Assertion(this, null, shouldGetter);
|
|
10274
|
+
}
|
|
10275
|
+
__name(shouldGetter, "shouldGetter");
|
|
10276
|
+
function shouldSetter(value) {
|
|
10277
|
+
Object.defineProperty(this, "should", {
|
|
10278
|
+
value,
|
|
10279
|
+
enumerable: true,
|
|
10280
|
+
configurable: true,
|
|
10281
|
+
writable: true
|
|
10282
|
+
});
|
|
10283
|
+
}
|
|
10284
|
+
__name(shouldSetter, "shouldSetter");
|
|
10285
|
+
Object.defineProperty(Object.prototype, "should", {
|
|
10286
|
+
set: shouldSetter,
|
|
10287
|
+
get: shouldGetter,
|
|
10288
|
+
configurable: true
|
|
10289
|
+
});
|
|
10290
|
+
let should2 = {};
|
|
10291
|
+
should2.fail = function(actual, expected, message, operator) {
|
|
10292
|
+
if (arguments.length < 2) {
|
|
10293
|
+
message = actual;
|
|
10294
|
+
actual = void 0;
|
|
10295
|
+
}
|
|
10296
|
+
message = message || "should.fail()";
|
|
10297
|
+
throw new AssertionError(message, {
|
|
10298
|
+
actual,
|
|
10299
|
+
expected,
|
|
10300
|
+
operator
|
|
10301
|
+
}, should2.fail);
|
|
10302
|
+
};
|
|
10303
|
+
should2.equal = function(actual, expected, message) {
|
|
10304
|
+
new Assertion(actual, message).to.equal(expected);
|
|
10305
|
+
};
|
|
10306
|
+
should2.Throw = function(fn, errt, errs, msg) {
|
|
10307
|
+
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
10308
|
+
};
|
|
10309
|
+
should2.exist = function(val, msg) {
|
|
10310
|
+
new Assertion(val, msg).to.exist;
|
|
10311
|
+
};
|
|
10312
|
+
should2.not = {};
|
|
10313
|
+
should2.not.equal = function(actual, expected, msg) {
|
|
10314
|
+
new Assertion(actual, msg).to.not.equal(expected);
|
|
10315
|
+
};
|
|
10316
|
+
should2.not.Throw = function(fn, errt, errs, msg) {
|
|
10317
|
+
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
10318
|
+
};
|
|
10319
|
+
should2.not.exist = function(val, msg) {
|
|
10320
|
+
new Assertion(val, msg).to.not.exist;
|
|
10321
|
+
};
|
|
10322
|
+
should2["throw"] = should2["Throw"];
|
|
10323
|
+
should2.not["throw"] = should2.not["Throw"];
|
|
10324
|
+
return should2;
|
|
10325
|
+
}
|
|
10326
|
+
__name(loadShould, "loadShould");
|
|
10327
|
+
var should = loadShould;
|
|
10328
|
+
var Should = loadShould;
|
|
10329
|
+
function assert(express, errmsg) {
|
|
10330
|
+
let test2 = new Assertion(null, null, assert, true);
|
|
10331
|
+
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
10332
|
+
}
|
|
10333
|
+
__name(assert, "assert");
|
|
10334
|
+
assert.fail = function(actual, expected, message, operator) {
|
|
10335
|
+
if (arguments.length < 2) {
|
|
10336
|
+
message = actual;
|
|
10337
|
+
actual = void 0;
|
|
10338
|
+
}
|
|
10339
|
+
message = message || "assert.fail()";
|
|
10340
|
+
throw new AssertionError(message, {
|
|
10341
|
+
actual,
|
|
10342
|
+
expected,
|
|
10343
|
+
operator
|
|
10344
|
+
}, assert.fail);
|
|
10345
|
+
};
|
|
10346
|
+
assert.isOk = function(val, msg) {
|
|
10347
|
+
new Assertion(val, msg, assert.isOk, true).is.ok;
|
|
10348
|
+
};
|
|
10349
|
+
assert.isNotOk = function(val, msg) {
|
|
10350
|
+
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
10351
|
+
};
|
|
10352
|
+
assert.equal = function(act, exp, msg) {
|
|
10353
|
+
let test2 = new Assertion(act, msg, assert.equal, true);
|
|
10354
|
+
test2.assert(exp == flag(test2, "object"), "expected #{this} to equal #{exp}", "expected #{this} to not equal #{act}", exp, act, true);
|
|
10355
|
+
};
|
|
10356
|
+
assert.notEqual = function(act, exp, msg) {
|
|
10357
|
+
let test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
10358
|
+
test2.assert(exp != flag(test2, "object"), "expected #{this} to not equal #{exp}", "expected #{this} to equal #{act}", exp, act, true);
|
|
10359
|
+
};
|
|
10360
|
+
assert.strictEqual = function(act, exp, msg) {
|
|
10361
|
+
new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
|
|
10362
|
+
};
|
|
10363
|
+
assert.notStrictEqual = function(act, exp, msg) {
|
|
10364
|
+
new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
|
|
10365
|
+
};
|
|
10366
|
+
assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
|
|
10367
|
+
new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
|
|
10368
|
+
};
|
|
10369
|
+
assert.notDeepEqual = function(act, exp, msg) {
|
|
10370
|
+
new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
|
|
10371
|
+
};
|
|
10372
|
+
assert.isAbove = function(val, abv, msg) {
|
|
10373
|
+
new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
|
|
10374
|
+
};
|
|
10375
|
+
assert.isAtLeast = function(val, atlst, msg) {
|
|
10376
|
+
new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
|
|
10377
|
+
};
|
|
10378
|
+
assert.isBelow = function(val, blw, msg) {
|
|
10379
|
+
new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
|
|
10380
|
+
};
|
|
10381
|
+
assert.isAtMost = function(val, atmst, msg) {
|
|
10382
|
+
new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
|
|
10383
|
+
};
|
|
10384
|
+
assert.isTrue = function(val, msg) {
|
|
10385
|
+
new Assertion(val, msg, assert.isTrue, true).is["true"];
|
|
10386
|
+
};
|
|
10387
|
+
assert.isNotTrue = function(val, msg) {
|
|
10388
|
+
new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
|
|
10389
|
+
};
|
|
10390
|
+
assert.isFalse = function(val, msg) {
|
|
10391
|
+
new Assertion(val, msg, assert.isFalse, true).is["false"];
|
|
10392
|
+
};
|
|
10393
|
+
assert.isNotFalse = function(val, msg) {
|
|
10394
|
+
new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
|
|
10395
|
+
};
|
|
10396
|
+
assert.isNull = function(val, msg) {
|
|
10397
|
+
new Assertion(val, msg, assert.isNull, true).to.equal(null);
|
|
10398
|
+
};
|
|
10399
|
+
assert.isNotNull = function(val, msg) {
|
|
10400
|
+
new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
|
|
10401
|
+
};
|
|
10402
|
+
assert.isNaN = function(val, msg) {
|
|
10403
|
+
new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
|
|
10404
|
+
};
|
|
10405
|
+
assert.isNotNaN = function(value, message) {
|
|
10406
|
+
new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
|
|
10407
|
+
};
|
|
10408
|
+
assert.exists = function(val, msg) {
|
|
10409
|
+
new Assertion(val, msg, assert.exists, true).to.exist;
|
|
10410
|
+
};
|
|
10411
|
+
assert.notExists = function(val, msg) {
|
|
10412
|
+
new Assertion(val, msg, assert.notExists, true).to.not.exist;
|
|
10413
|
+
};
|
|
10414
|
+
assert.isUndefined = function(val, msg) {
|
|
10415
|
+
new Assertion(val, msg, assert.isUndefined, true).to.equal(void 0);
|
|
10416
|
+
};
|
|
10417
|
+
assert.isDefined = function(val, msg) {
|
|
10418
|
+
new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
|
|
10419
|
+
};
|
|
10420
|
+
assert.isCallable = function(value, message) {
|
|
10421
|
+
new Assertion(value, message, assert.isCallable, true).is.callable;
|
|
10422
|
+
};
|
|
10423
|
+
assert.isNotCallable = function(value, message) {
|
|
10424
|
+
new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
|
|
10425
|
+
};
|
|
10426
|
+
assert.isObject = function(val, msg) {
|
|
10427
|
+
new Assertion(val, msg, assert.isObject, true).to.be.a("object");
|
|
10428
|
+
};
|
|
10429
|
+
assert.isNotObject = function(val, msg) {
|
|
10430
|
+
new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
|
|
10431
|
+
};
|
|
10432
|
+
assert.isArray = function(val, msg) {
|
|
10433
|
+
new Assertion(val, msg, assert.isArray, true).to.be.an("array");
|
|
10434
|
+
};
|
|
10435
|
+
assert.isNotArray = function(val, msg) {
|
|
10436
|
+
new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
|
|
10437
|
+
};
|
|
10438
|
+
assert.isString = function(val, msg) {
|
|
10439
|
+
new Assertion(val, msg, assert.isString, true).to.be.a("string");
|
|
10440
|
+
};
|
|
10441
|
+
assert.isNotString = function(val, msg) {
|
|
10442
|
+
new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
|
|
10443
|
+
};
|
|
10444
|
+
assert.isNumber = function(val, msg) {
|
|
10445
|
+
new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
|
|
10446
|
+
};
|
|
10447
|
+
assert.isNotNumber = function(val, msg) {
|
|
10448
|
+
new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
|
|
10449
|
+
};
|
|
10450
|
+
assert.isNumeric = function(val, msg) {
|
|
10451
|
+
new Assertion(val, msg, assert.isNumeric, true).is.numeric;
|
|
10452
|
+
};
|
|
10453
|
+
assert.isNotNumeric = function(val, msg) {
|
|
10454
|
+
new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
|
|
10455
|
+
};
|
|
10456
|
+
assert.isFinite = function(val, msg) {
|
|
10457
|
+
new Assertion(val, msg, assert.isFinite, true).to.be.finite;
|
|
10458
|
+
};
|
|
10459
|
+
assert.isBoolean = function(val, msg) {
|
|
10460
|
+
new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
|
|
10461
|
+
};
|
|
10462
|
+
assert.isNotBoolean = function(val, msg) {
|
|
10463
|
+
new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
|
|
10464
|
+
};
|
|
10465
|
+
assert.typeOf = function(val, type3, msg) {
|
|
10466
|
+
new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
|
|
10467
|
+
};
|
|
10468
|
+
assert.notTypeOf = function(value, type3, message) {
|
|
10469
|
+
new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
|
|
10470
|
+
};
|
|
10471
|
+
assert.instanceOf = function(val, type3, msg) {
|
|
10472
|
+
new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
|
|
10473
|
+
};
|
|
10474
|
+
assert.notInstanceOf = function(val, type3, msg) {
|
|
10475
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(type3);
|
|
10476
|
+
};
|
|
10477
|
+
assert.include = function(exp, inc, msg) {
|
|
10478
|
+
new Assertion(exp, msg, assert.include, true).include(inc);
|
|
10479
|
+
};
|
|
10480
|
+
assert.notInclude = function(exp, inc, msg) {
|
|
10481
|
+
new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
|
|
10482
|
+
};
|
|
10483
|
+
assert.deepInclude = function(exp, inc, msg) {
|
|
10484
|
+
new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
|
|
10485
|
+
};
|
|
10486
|
+
assert.notDeepInclude = function(exp, inc, msg) {
|
|
10487
|
+
new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
|
|
10488
|
+
};
|
|
10489
|
+
assert.nestedInclude = function(exp, inc, msg) {
|
|
10490
|
+
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
10491
|
+
};
|
|
10492
|
+
assert.notNestedInclude = function(exp, inc, msg) {
|
|
10493
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(inc);
|
|
10494
|
+
};
|
|
10495
|
+
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
10496
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(inc);
|
|
10497
|
+
};
|
|
10498
|
+
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
10499
|
+
new Assertion(exp, msg, assert.notDeepNestedInclude, true).not.deep.nested.include(inc);
|
|
10500
|
+
};
|
|
10501
|
+
assert.ownInclude = function(exp, inc, msg) {
|
|
10502
|
+
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
10503
|
+
};
|
|
10504
|
+
assert.notOwnInclude = function(exp, inc, msg) {
|
|
10505
|
+
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
|
|
10506
|
+
};
|
|
10507
|
+
assert.deepOwnInclude = function(exp, inc, msg) {
|
|
10508
|
+
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
10509
|
+
};
|
|
10510
|
+
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
10511
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(inc);
|
|
10512
|
+
};
|
|
10513
|
+
assert.match = function(exp, re, msg) {
|
|
10514
|
+
new Assertion(exp, msg, assert.match, true).to.match(re);
|
|
10515
|
+
};
|
|
10516
|
+
assert.notMatch = function(exp, re, msg) {
|
|
10517
|
+
new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
|
|
10518
|
+
};
|
|
10519
|
+
assert.property = function(obj, prop, msg) {
|
|
10520
|
+
new Assertion(obj, msg, assert.property, true).to.have.property(prop);
|
|
10521
|
+
};
|
|
10522
|
+
assert.notProperty = function(obj, prop, msg) {
|
|
10523
|
+
new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
|
|
10524
|
+
};
|
|
10525
|
+
assert.propertyVal = function(obj, prop, val, msg) {
|
|
10526
|
+
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
10527
|
+
};
|
|
10528
|
+
assert.notPropertyVal = function(obj, prop, val, msg) {
|
|
10529
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(prop, val);
|
|
10530
|
+
};
|
|
10531
|
+
assert.deepPropertyVal = function(obj, prop, val, msg) {
|
|
10532
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(prop, val);
|
|
10533
|
+
};
|
|
10534
|
+
assert.notDeepPropertyVal = function(obj, prop, val, msg) {
|
|
10535
|
+
new Assertion(obj, msg, assert.notDeepPropertyVal, true).to.not.have.deep.property(prop, val);
|
|
10536
|
+
};
|
|
10537
|
+
assert.ownProperty = function(obj, prop, msg) {
|
|
10538
|
+
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
10539
|
+
};
|
|
10540
|
+
assert.notOwnProperty = function(obj, prop, msg) {
|
|
10541
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(prop);
|
|
10542
|
+
};
|
|
10543
|
+
assert.ownPropertyVal = function(obj, prop, value, msg) {
|
|
10544
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(prop, value);
|
|
10545
|
+
};
|
|
10546
|
+
assert.notOwnPropertyVal = function(obj, prop, value, msg) {
|
|
10547
|
+
new Assertion(obj, msg, assert.notOwnPropertyVal, true).to.not.have.own.property(prop, value);
|
|
10548
|
+
};
|
|
10549
|
+
assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
10550
|
+
new Assertion(obj, msg, assert.deepOwnPropertyVal, true).to.have.deep.own.property(prop, value);
|
|
10551
|
+
};
|
|
10552
|
+
assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
10553
|
+
new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true).to.not.have.deep.own.property(prop, value);
|
|
10554
|
+
};
|
|
10555
|
+
assert.nestedProperty = function(obj, prop, msg) {
|
|
10556
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(prop);
|
|
10557
|
+
};
|
|
10558
|
+
assert.notNestedProperty = function(obj, prop, msg) {
|
|
10559
|
+
new Assertion(obj, msg, assert.notNestedProperty, true).to.not.have.nested.property(prop);
|
|
10560
|
+
};
|
|
10561
|
+
assert.nestedPropertyVal = function(obj, prop, val, msg) {
|
|
10562
|
+
new Assertion(obj, msg, assert.nestedPropertyVal, true).to.have.nested.property(prop, val);
|
|
10563
|
+
};
|
|
10564
|
+
assert.notNestedPropertyVal = function(obj, prop, val, msg) {
|
|
10565
|
+
new Assertion(obj, msg, assert.notNestedPropertyVal, true).to.not.have.nested.property(prop, val);
|
|
10566
|
+
};
|
|
10567
|
+
assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
10568
|
+
new Assertion(obj, msg, assert.deepNestedPropertyVal, true).to.have.deep.nested.property(prop, val);
|
|
10569
|
+
};
|
|
10570
|
+
assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
10571
|
+
new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true).to.not.have.deep.nested.property(prop, val);
|
|
10572
|
+
};
|
|
10573
|
+
assert.lengthOf = function(exp, len, msg) {
|
|
10574
|
+
new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
|
|
10575
|
+
};
|
|
10576
|
+
assert.hasAnyKeys = function(obj, keys, msg) {
|
|
10577
|
+
new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
|
|
10578
|
+
};
|
|
10579
|
+
assert.hasAllKeys = function(obj, keys, msg) {
|
|
10580
|
+
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
10581
|
+
};
|
|
10582
|
+
assert.containsAllKeys = function(obj, keys, msg) {
|
|
10583
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(keys);
|
|
10584
|
+
};
|
|
10585
|
+
assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
|
|
10586
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(keys);
|
|
10587
|
+
};
|
|
10588
|
+
assert.doesNotHaveAllKeys = function(obj, keys, msg) {
|
|
10589
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(keys);
|
|
10590
|
+
};
|
|
10591
|
+
assert.hasAnyDeepKeys = function(obj, keys, msg) {
|
|
10592
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(keys);
|
|
10593
|
+
};
|
|
10594
|
+
assert.hasAllDeepKeys = function(obj, keys, msg) {
|
|
10595
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(keys);
|
|
10596
|
+
};
|
|
10597
|
+
assert.containsAllDeepKeys = function(obj, keys, msg) {
|
|
10598
|
+
new Assertion(obj, msg, assert.containsAllDeepKeys, true).to.contain.all.deep.keys(keys);
|
|
10599
|
+
};
|
|
10600
|
+
assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
|
|
10601
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true).to.not.have.any.deep.keys(keys);
|
|
10602
|
+
};
|
|
10603
|
+
assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
|
|
10604
|
+
new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true).to.not.have.all.deep.keys(keys);
|
|
10605
|
+
};
|
|
10606
|
+
assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
10607
|
+
if ("string" == typeof errorLike || errorLike instanceof RegExp) {
|
|
10608
|
+
errMsgMatcher = errorLike;
|
|
10609
|
+
errorLike = null;
|
|
10610
|
+
}
|
|
10611
|
+
let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher);
|
|
10612
|
+
return flag(assertErr, "object");
|
|
10613
|
+
};
|
|
10614
|
+
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
10615
|
+
if ("string" == typeof errorLike || errorLike instanceof RegExp) {
|
|
10616
|
+
errMsgMatcher = errorLike;
|
|
10617
|
+
errorLike = null;
|
|
10618
|
+
}
|
|
10619
|
+
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
|
|
10620
|
+
};
|
|
10621
|
+
assert.operator = function(val, operator, val2, msg) {
|
|
10622
|
+
let ok;
|
|
10623
|
+
switch(operator){
|
|
10624
|
+
case "==":
|
|
10625
|
+
ok = val == val2;
|
|
10626
|
+
break;
|
|
10627
|
+
case "===":
|
|
10628
|
+
ok = val === val2;
|
|
10629
|
+
break;
|
|
10630
|
+
case ">":
|
|
10631
|
+
ok = val > val2;
|
|
10632
|
+
break;
|
|
10633
|
+
case ">=":
|
|
10634
|
+
ok = val >= val2;
|
|
10635
|
+
break;
|
|
10636
|
+
case "<":
|
|
10637
|
+
ok = val < val2;
|
|
10638
|
+
break;
|
|
10639
|
+
case "<=":
|
|
10640
|
+
ok = val <= val2;
|
|
10641
|
+
break;
|
|
10642
|
+
case "!=":
|
|
10643
|
+
ok = val != val2;
|
|
10644
|
+
break;
|
|
10645
|
+
case "!==":
|
|
10646
|
+
ok = val !== val2;
|
|
10647
|
+
break;
|
|
10648
|
+
default:
|
|
10649
|
+
msg = msg ? msg + ": " : msg;
|
|
10650
|
+
throw new AssertionError(msg + 'Invalid operator "' + operator + '"', void 0, assert.operator);
|
|
10651
|
+
}
|
|
10652
|
+
let test2 = new Assertion(ok, msg, assert.operator, true);
|
|
10653
|
+
test2.assert(true === flag(test2, "object"), "expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2), "expected " + inspect2(val) + " to not be " + operator + " " + inspect2(val2));
|
|
10654
|
+
};
|
|
10655
|
+
assert.closeTo = function(act, exp, delta, msg) {
|
|
10656
|
+
new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
|
|
10657
|
+
};
|
|
10658
|
+
assert.approximately = function(act, exp, delta, msg) {
|
|
10659
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(exp, delta);
|
|
10660
|
+
};
|
|
10661
|
+
assert.sameMembers = function(set1, set2, msg) {
|
|
10662
|
+
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
10663
|
+
};
|
|
10664
|
+
assert.notSameMembers = function(set1, set2, msg) {
|
|
10665
|
+
new Assertion(set1, msg, assert.notSameMembers, true).to.not.have.same.members(set2);
|
|
10666
|
+
};
|
|
10667
|
+
assert.sameDeepMembers = function(set1, set2, msg) {
|
|
10668
|
+
new Assertion(set1, msg, assert.sameDeepMembers, true).to.have.same.deep.members(set2);
|
|
10669
|
+
};
|
|
10670
|
+
assert.notSameDeepMembers = function(set1, set2, msg) {
|
|
10671
|
+
new Assertion(set1, msg, assert.notSameDeepMembers, true).to.not.have.same.deep.members(set2);
|
|
10672
|
+
};
|
|
10673
|
+
assert.sameOrderedMembers = function(set1, set2, msg) {
|
|
10674
|
+
new Assertion(set1, msg, assert.sameOrderedMembers, true).to.have.same.ordered.members(set2);
|
|
10675
|
+
};
|
|
10676
|
+
assert.notSameOrderedMembers = function(set1, set2, msg) {
|
|
10677
|
+
new Assertion(set1, msg, assert.notSameOrderedMembers, true).to.not.have.same.ordered.members(set2);
|
|
10678
|
+
};
|
|
10679
|
+
assert.sameDeepOrderedMembers = function(set1, set2, msg) {
|
|
10680
|
+
new Assertion(set1, msg, assert.sameDeepOrderedMembers, true).to.have.same.deep.ordered.members(set2);
|
|
10681
|
+
};
|
|
10682
|
+
assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
|
|
10683
|
+
new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true).to.not.have.same.deep.ordered.members(set2);
|
|
10684
|
+
};
|
|
10685
|
+
assert.includeMembers = function(superset, subset, msg) {
|
|
10686
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(subset);
|
|
10687
|
+
};
|
|
10688
|
+
assert.notIncludeMembers = function(superset, subset, msg) {
|
|
10689
|
+
new Assertion(superset, msg, assert.notIncludeMembers, true).to.not.include.members(subset);
|
|
10690
|
+
};
|
|
10691
|
+
assert.includeDeepMembers = function(superset, subset, msg) {
|
|
10692
|
+
new Assertion(superset, msg, assert.includeDeepMembers, true).to.include.deep.members(subset);
|
|
10693
|
+
};
|
|
10694
|
+
assert.notIncludeDeepMembers = function(superset, subset, msg) {
|
|
10695
|
+
new Assertion(superset, msg, assert.notIncludeDeepMembers, true).to.not.include.deep.members(subset);
|
|
10696
|
+
};
|
|
10697
|
+
assert.includeOrderedMembers = function(superset, subset, msg) {
|
|
10698
|
+
new Assertion(superset, msg, assert.includeOrderedMembers, true).to.include.ordered.members(subset);
|
|
10699
|
+
};
|
|
10700
|
+
assert.notIncludeOrderedMembers = function(superset, subset, msg) {
|
|
10701
|
+
new Assertion(superset, msg, assert.notIncludeOrderedMembers, true).to.not.include.ordered.members(subset);
|
|
10702
|
+
};
|
|
10703
|
+
assert.includeDeepOrderedMembers = function(superset, subset, msg) {
|
|
10704
|
+
new Assertion(superset, msg, assert.includeDeepOrderedMembers, true).to.include.deep.ordered.members(subset);
|
|
10705
|
+
};
|
|
10706
|
+
assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
|
|
10707
|
+
new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true).to.not.include.deep.ordered.members(subset);
|
|
10708
|
+
};
|
|
10709
|
+
assert.oneOf = function(inList, list, msg) {
|
|
10710
|
+
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
10711
|
+
};
|
|
10712
|
+
assert.isIterable = function(obj, msg) {
|
|
10713
|
+
if (void 0 == obj || !obj[Symbol.iterator]) {
|
|
10714
|
+
msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
|
|
10715
|
+
throw new AssertionError(msg, void 0, assert.isIterable);
|
|
10716
|
+
}
|
|
10717
|
+
};
|
|
10718
|
+
assert.changes = function(fn, obj, prop, msg) {
|
|
10719
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10720
|
+
msg = prop;
|
|
10721
|
+
prop = null;
|
|
10722
|
+
}
|
|
10723
|
+
new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
|
|
10724
|
+
};
|
|
10725
|
+
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
10726
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10727
|
+
let tmpMsg = delta;
|
|
10728
|
+
delta = prop;
|
|
10729
|
+
msg = tmpMsg;
|
|
10730
|
+
} else if (3 === arguments.length) {
|
|
10731
|
+
delta = prop;
|
|
10732
|
+
prop = null;
|
|
10733
|
+
}
|
|
10734
|
+
new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
|
|
10735
|
+
};
|
|
10736
|
+
assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
10737
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10738
|
+
msg = prop;
|
|
10739
|
+
prop = null;
|
|
10740
|
+
}
|
|
10741
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(obj, prop);
|
|
10742
|
+
};
|
|
10743
|
+
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
10744
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10745
|
+
let tmpMsg = delta;
|
|
10746
|
+
delta = prop;
|
|
10747
|
+
msg = tmpMsg;
|
|
10748
|
+
} else if (3 === arguments.length) {
|
|
10749
|
+
delta = prop;
|
|
10750
|
+
prop = null;
|
|
10751
|
+
}
|
|
10752
|
+
new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
|
|
10753
|
+
};
|
|
10754
|
+
assert.increases = function(fn, obj, prop, msg) {
|
|
10755
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10756
|
+
msg = prop;
|
|
10757
|
+
prop = null;
|
|
10758
|
+
}
|
|
10759
|
+
return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
|
|
10760
|
+
};
|
|
10761
|
+
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
10762
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10763
|
+
let tmpMsg = delta;
|
|
10764
|
+
delta = prop;
|
|
10765
|
+
msg = tmpMsg;
|
|
10766
|
+
} else if (3 === arguments.length) {
|
|
10767
|
+
delta = prop;
|
|
10768
|
+
prop = null;
|
|
10769
|
+
}
|
|
10770
|
+
new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
|
|
10771
|
+
};
|
|
10772
|
+
assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
10773
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10774
|
+
msg = prop;
|
|
10775
|
+
prop = null;
|
|
10776
|
+
}
|
|
10777
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(obj, prop);
|
|
10778
|
+
};
|
|
10779
|
+
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
10780
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10781
|
+
let tmpMsg = delta;
|
|
10782
|
+
delta = prop;
|
|
10783
|
+
msg = tmpMsg;
|
|
10784
|
+
} else if (3 === arguments.length) {
|
|
10785
|
+
delta = prop;
|
|
10786
|
+
prop = null;
|
|
10787
|
+
}
|
|
10788
|
+
new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
|
|
10789
|
+
};
|
|
10790
|
+
assert.decreases = function(fn, obj, prop, msg) {
|
|
10791
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10792
|
+
msg = prop;
|
|
10793
|
+
prop = null;
|
|
10794
|
+
}
|
|
10795
|
+
return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
|
|
10796
|
+
};
|
|
10797
|
+
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
10798
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10799
|
+
let tmpMsg = delta;
|
|
10800
|
+
delta = prop;
|
|
10801
|
+
msg = tmpMsg;
|
|
10802
|
+
} else if (3 === arguments.length) {
|
|
10803
|
+
delta = prop;
|
|
10804
|
+
prop = null;
|
|
10805
|
+
}
|
|
10806
|
+
new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
|
|
10807
|
+
};
|
|
10808
|
+
assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
10809
|
+
if (3 === arguments.length && "function" == typeof obj) {
|
|
10810
|
+
msg = prop;
|
|
10811
|
+
prop = null;
|
|
10812
|
+
}
|
|
10813
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(obj, prop);
|
|
10814
|
+
};
|
|
10815
|
+
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
10816
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10817
|
+
let tmpMsg = delta;
|
|
10818
|
+
delta = prop;
|
|
10819
|
+
msg = tmpMsg;
|
|
10820
|
+
} else if (3 === arguments.length) {
|
|
10821
|
+
delta = prop;
|
|
10822
|
+
prop = null;
|
|
10823
|
+
}
|
|
10824
|
+
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
|
|
10825
|
+
};
|
|
10826
|
+
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
10827
|
+
if (4 === arguments.length && "function" == typeof obj) {
|
|
10828
|
+
let tmpMsg = delta;
|
|
10829
|
+
delta = prop;
|
|
10830
|
+
msg = tmpMsg;
|
|
10831
|
+
} else if (3 === arguments.length) {
|
|
10832
|
+
delta = prop;
|
|
10833
|
+
prop = null;
|
|
10834
|
+
}
|
|
10835
|
+
new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
|
|
10836
|
+
};
|
|
10837
|
+
assert.ifError = function(val) {
|
|
10838
|
+
if (val) throw val;
|
|
10839
|
+
};
|
|
10840
|
+
assert.isExtensible = function(obj, msg) {
|
|
10841
|
+
new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
|
|
10842
|
+
};
|
|
10843
|
+
assert.isNotExtensible = function(obj, msg) {
|
|
10844
|
+
new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
|
|
10845
|
+
};
|
|
10846
|
+
assert.isSealed = function(obj, msg) {
|
|
10847
|
+
new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
|
|
10848
|
+
};
|
|
10849
|
+
assert.isNotSealed = function(obj, msg) {
|
|
10850
|
+
new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
|
|
10851
|
+
};
|
|
10852
|
+
assert.isFrozen = function(obj, msg) {
|
|
10853
|
+
new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
|
|
10854
|
+
};
|
|
10855
|
+
assert.isNotFrozen = function(obj, msg) {
|
|
10856
|
+
new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
|
|
10857
|
+
};
|
|
10858
|
+
assert.isEmpty = function(val, msg) {
|
|
10859
|
+
new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
|
|
10860
|
+
};
|
|
10861
|
+
assert.isNotEmpty = function(val, msg) {
|
|
10862
|
+
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
10863
|
+
};
|
|
10864
|
+
assert.containsSubset = function(val, exp, msg) {
|
|
10865
|
+
new Assertion(val, msg).to.containSubset(exp);
|
|
10866
|
+
};
|
|
10867
|
+
assert.doesNotContainSubset = function(val, exp, msg) {
|
|
10868
|
+
new Assertion(val, msg).to.not.containSubset(exp);
|
|
10869
|
+
};
|
|
10870
|
+
var aliases = [
|
|
10871
|
+
[
|
|
10872
|
+
"isOk",
|
|
10873
|
+
"ok"
|
|
10874
|
+
],
|
|
10875
|
+
[
|
|
10876
|
+
"isNotOk",
|
|
10877
|
+
"notOk"
|
|
10878
|
+
],
|
|
10879
|
+
[
|
|
10880
|
+
"throws",
|
|
10881
|
+
"throw"
|
|
10882
|
+
],
|
|
10883
|
+
[
|
|
10884
|
+
"throws",
|
|
10885
|
+
"Throw"
|
|
10886
|
+
],
|
|
10887
|
+
[
|
|
10888
|
+
"isExtensible",
|
|
10889
|
+
"extensible"
|
|
10890
|
+
],
|
|
10891
|
+
[
|
|
10892
|
+
"isNotExtensible",
|
|
10893
|
+
"notExtensible"
|
|
10894
|
+
],
|
|
10895
|
+
[
|
|
10896
|
+
"isSealed",
|
|
10897
|
+
"sealed"
|
|
10898
|
+
],
|
|
10899
|
+
[
|
|
10900
|
+
"isNotSealed",
|
|
10901
|
+
"notSealed"
|
|
10902
|
+
],
|
|
10903
|
+
[
|
|
10904
|
+
"isFrozen",
|
|
10905
|
+
"frozen"
|
|
10906
|
+
],
|
|
10907
|
+
[
|
|
10908
|
+
"isNotFrozen",
|
|
10909
|
+
"notFrozen"
|
|
10910
|
+
],
|
|
10911
|
+
[
|
|
10912
|
+
"isEmpty",
|
|
10913
|
+
"empty"
|
|
10914
|
+
],
|
|
10915
|
+
[
|
|
10916
|
+
"isNotEmpty",
|
|
10917
|
+
"notEmpty"
|
|
10918
|
+
],
|
|
10919
|
+
[
|
|
10920
|
+
"isCallable",
|
|
10921
|
+
"isFunction"
|
|
10922
|
+
],
|
|
10923
|
+
[
|
|
10924
|
+
"isNotCallable",
|
|
10925
|
+
"isNotFunction"
|
|
10926
|
+
],
|
|
10927
|
+
[
|
|
10928
|
+
"containsSubset",
|
|
10929
|
+
"containSubset"
|
|
10930
|
+
]
|
|
10931
|
+
];
|
|
10932
|
+
for (const [name, as] of aliases)assert[as] = assert[name];
|
|
10933
|
+
var used = [];
|
|
10934
|
+
function use(fn) {
|
|
10935
|
+
const exports = {
|
|
10936
|
+
use,
|
|
10937
|
+
AssertionError,
|
|
10938
|
+
util: utils_exports,
|
|
10939
|
+
config,
|
|
10940
|
+
expect,
|
|
10941
|
+
assert,
|
|
10942
|
+
Assertion,
|
|
10943
|
+
...should_exports
|
|
10944
|
+
};
|
|
10945
|
+
if (!~used.indexOf(fn)) {
|
|
10946
|
+
fn(exports, utils_exports);
|
|
10947
|
+
used.push(fn);
|
|
10948
|
+
}
|
|
10949
|
+
return exports;
|
|
10950
|
+
}
|
|
10951
|
+
__name(use, "use");
|
|
10952
|
+
/*!
|
|
10953
|
+
* Chai - flag utility
|
|
10954
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10955
|
+
* MIT Licensed
|
|
10956
|
+
*/ /*!
|
|
10957
|
+
* Chai - test utility
|
|
10958
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10959
|
+
* MIT Licensed
|
|
10960
|
+
*/ /*!
|
|
10961
|
+
* Chai - expectTypes utility
|
|
10962
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10963
|
+
* MIT Licensed
|
|
10964
|
+
*/ /*!
|
|
10965
|
+
* Chai - getActual utility
|
|
10966
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10967
|
+
* MIT Licensed
|
|
10968
|
+
*/ /*!
|
|
10969
|
+
* Chai - message composition utility
|
|
10970
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10971
|
+
* MIT Licensed
|
|
10972
|
+
*/ /*!
|
|
10973
|
+
* Chai - transferFlags utility
|
|
10974
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10975
|
+
* MIT Licensed
|
|
10976
|
+
*/ /*!
|
|
10977
|
+
* chai
|
|
10978
|
+
* http://chaijs.com
|
|
10979
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10980
|
+
* MIT Licensed
|
|
10981
|
+
*/ /*!
|
|
10982
|
+
* Chai - isProxyEnabled helper
|
|
10983
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10984
|
+
* MIT Licensed
|
|
10985
|
+
*/ /*!
|
|
10986
|
+
* Chai - addProperty utility
|
|
10987
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10988
|
+
* MIT Licensed
|
|
10989
|
+
*/ /*!
|
|
10990
|
+
* Chai - addLengthGuard utility
|
|
10991
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10992
|
+
* MIT Licensed
|
|
10993
|
+
*/ /*!
|
|
10994
|
+
* Chai - getProperties utility
|
|
10995
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
10996
|
+
* MIT Licensed
|
|
10997
|
+
*/ /*!
|
|
10998
|
+
* Chai - proxify utility
|
|
10999
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11000
|
+
* MIT Licensed
|
|
11001
|
+
*/ /*!
|
|
11002
|
+
* Chai - addMethod utility
|
|
11003
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11004
|
+
* MIT Licensed
|
|
11005
|
+
*/ /*!
|
|
11006
|
+
* Chai - overwriteProperty utility
|
|
11007
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11008
|
+
* MIT Licensed
|
|
11009
|
+
*/ /*!
|
|
11010
|
+
* Chai - overwriteMethod utility
|
|
11011
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11012
|
+
* MIT Licensed
|
|
11013
|
+
*/ /*!
|
|
11014
|
+
* Chai - addChainingMethod utility
|
|
11015
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11016
|
+
* MIT Licensed
|
|
11017
|
+
*/ /*!
|
|
11018
|
+
* Chai - overwriteChainableMethod utility
|
|
11019
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11020
|
+
* MIT Licensed
|
|
11021
|
+
*/ /*!
|
|
11022
|
+
* Chai - compareByInspect utility
|
|
11023
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
11024
|
+
* MIT Licensed
|
|
11025
|
+
*/ /*!
|
|
11026
|
+
* Chai - getOwnEnumerablePropertySymbols utility
|
|
11027
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
11028
|
+
* MIT Licensed
|
|
11029
|
+
*/ /*!
|
|
11030
|
+
* Chai - getOwnEnumerableProperties utility
|
|
11031
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
11032
|
+
* MIT Licensed
|
|
11033
|
+
*/ /*!
|
|
11034
|
+
* Chai - isNaN utility
|
|
11035
|
+
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
11036
|
+
* MIT Licensed
|
|
11037
|
+
*/ /*!
|
|
11038
|
+
* chai
|
|
11039
|
+
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
11040
|
+
* MIT Licensed
|
|
11041
|
+
*/ /*!
|
|
11042
|
+
* chai
|
|
11043
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
11044
|
+
* MIT Licensed
|
|
11045
|
+
*/ /*! Bundled license information:
|
|
11046
|
+
|
|
11047
|
+
deep-eql/index.js:
|
|
11048
|
+
(*!
|
|
11049
|
+
* deep-eql
|
|
11050
|
+
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
11051
|
+
* MIT Licensed
|
|
11052
|
+
*)
|
|
11053
|
+
(*!
|
|
11054
|
+
* Check to see if the MemoizeMap has recorded a result of the two operands
|
|
11055
|
+
*
|
|
11056
|
+
* @param {Mixed} leftHandOperand
|
|
11057
|
+
* @param {Mixed} rightHandOperand
|
|
11058
|
+
* @param {MemoizeMap} memoizeMap
|
|
11059
|
+
* @returns {Boolean|null} result
|
|
11060
|
+
*)
|
|
11061
|
+
(*!
|
|
11062
|
+
* Set the result of the equality into the MemoizeMap
|
|
11063
|
+
*
|
|
11064
|
+
* @param {Mixed} leftHandOperand
|
|
11065
|
+
* @param {Mixed} rightHandOperand
|
|
11066
|
+
* @param {MemoizeMap} memoizeMap
|
|
11067
|
+
* @param {Boolean} result
|
|
11068
|
+
*)
|
|
11069
|
+
(*!
|
|
11070
|
+
* Primary Export
|
|
11071
|
+
*)
|
|
11072
|
+
(*!
|
|
11073
|
+
* The main logic of the `deepEqual` function.
|
|
11074
|
+
*
|
|
11075
|
+
* @param {Mixed} leftHandOperand
|
|
11076
|
+
* @param {Mixed} rightHandOperand
|
|
11077
|
+
* @param {Object} [options] (optional) Additional options
|
|
11078
|
+
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
|
11079
|
+
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
|
11080
|
+
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
|
11081
|
+
references to blow the stack.
|
|
11082
|
+
* @return {Boolean} equal match
|
|
11083
|
+
*)
|
|
11084
|
+
(*!
|
|
11085
|
+
* Compare two Regular Expressions for equality.
|
|
11086
|
+
*
|
|
11087
|
+
* @param {RegExp} leftHandOperand
|
|
11088
|
+
* @param {RegExp} rightHandOperand
|
|
11089
|
+
* @return {Boolean} result
|
|
11090
|
+
*)
|
|
11091
|
+
(*!
|
|
11092
|
+
* Compare two Sets/Maps for equality. Faster than other equality functions.
|
|
11093
|
+
*
|
|
11094
|
+
* @param {Set} leftHandOperand
|
|
11095
|
+
* @param {Set} rightHandOperand
|
|
11096
|
+
* @param {Object} [options] (Optional)
|
|
11097
|
+
* @return {Boolean} result
|
|
11098
|
+
*)
|
|
11099
|
+
(*!
|
|
11100
|
+
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
|
|
11101
|
+
*
|
|
11102
|
+
* @param {Iterable} leftHandOperand
|
|
11103
|
+
* @param {Iterable} rightHandOperand
|
|
11104
|
+
* @param {Object} [options] (Optional)
|
|
11105
|
+
* @return {Boolean} result
|
|
11106
|
+
*)
|
|
11107
|
+
(*!
|
|
11108
|
+
* Simple equality for generator objects such as those returned by generator functions.
|
|
11109
|
+
*
|
|
11110
|
+
* @param {Iterable} leftHandOperand
|
|
11111
|
+
* @param {Iterable} rightHandOperand
|
|
11112
|
+
* @param {Object} [options] (Optional)
|
|
11113
|
+
* @return {Boolean} result
|
|
11114
|
+
*)
|
|
11115
|
+
(*!
|
|
11116
|
+
* Determine if the given object has an @@iterator function.
|
|
11117
|
+
*
|
|
11118
|
+
* @param {Object} target
|
|
11119
|
+
* @return {Boolean} `true` if the object has an @@iterator function.
|
|
11120
|
+
*)
|
|
11121
|
+
(*!
|
|
11122
|
+
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
|
|
11123
|
+
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
|
|
11124
|
+
*
|
|
11125
|
+
* @param {Object} target
|
|
11126
|
+
* @returns {Array} an array of entries from the @@iterator function
|
|
11127
|
+
*)
|
|
11128
|
+
(*!
|
|
11129
|
+
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
|
|
11130
|
+
*
|
|
11131
|
+
* @param {Generator} target
|
|
11132
|
+
* @returns {Array} an array of entries from the Generator.
|
|
11133
|
+
*)
|
|
11134
|
+
(*!
|
|
11135
|
+
* Gets all own and inherited enumerable keys from a target.
|
|
11136
|
+
*
|
|
11137
|
+
* @param {Object} target
|
|
11138
|
+
* @returns {Array} an array of own and inherited enumerable keys from the target.
|
|
11139
|
+
*)
|
|
11140
|
+
(*!
|
|
11141
|
+
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
|
|
11142
|
+
* each key. If any value of the given key is not equal, the function will return false (early).
|
|
11143
|
+
*
|
|
11144
|
+
* @param {Mixed} leftHandOperand
|
|
11145
|
+
* @param {Mixed} rightHandOperand
|
|
11146
|
+
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
|
|
11147
|
+
* @param {Object} [options] (Optional)
|
|
11148
|
+
* @return {Boolean} result
|
|
11149
|
+
*)
|
|
11150
|
+
(*!
|
|
11151
|
+
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
|
|
11152
|
+
* for each enumerable key in the object.
|
|
11153
|
+
*
|
|
11154
|
+
* @param {Mixed} leftHandOperand
|
|
11155
|
+
* @param {Mixed} rightHandOperand
|
|
11156
|
+
* @param {Object} [options] (Optional)
|
|
11157
|
+
* @return {Boolean} result
|
|
11158
|
+
*)
|
|
11159
|
+
(*!
|
|
11160
|
+
* Returns true if the argument is a primitive.
|
|
11161
|
+
*
|
|
11162
|
+
* This intentionally returns true for all objects that can be compared by reference,
|
|
11163
|
+
* including functions and symbols.
|
|
11164
|
+
*
|
|
11165
|
+
* @param {Mixed} value
|
|
11166
|
+
* @return {Boolean} result
|
|
11167
|
+
*)
|
|
11168
|
+
*/ },
|
|
7979
11169
|
"../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
7980
11170
|
__webpack_require__.d(__webpack_exports__, {
|
|
7981
11171
|
Ay: ()=>node_u
|