@voidzero-dev/vite-plus-test 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vendor/chai.mjs +279 -738
- package/dist/vendor/es-module-lexer.mjs +4 -5
- package/dist/vendor/estree-walker.mjs +18 -47
- package/dist/vendor/expect-type.mjs +10 -100
- package/dist/vendor/magic-string.mjs +152 -577
- package/dist/vendor/obug.mjs +1 -4
- package/dist/vendor/pathe.mjs +64 -112
- package/dist/vendor/picomatch.mjs +131 -323
- package/dist/vendor/{shared-BL6rqJMI.mjs → shared-BelWnsAF.mjs} +7 -12
- package/dist/vendor/std-env.mjs +2 -4
- package/dist/vendor/tinybench.mjs +7 -8
- package/dist/vendor/tinyexec.mjs +13 -25
- package/dist/vendor/tinyglobby.mjs +10 -21
- package/dist/vendor/tinyrainbow.mjs +1 -2
- package/package.json +3 -3
package/dist/vendor/chai.mjs
CHANGED
|
@@ -72,55 +72,39 @@ function compatibleInstance(thrown, errorLike) {
|
|
|
72
72
|
}
|
|
73
73
|
__name(compatibleInstance, "compatibleInstance");
|
|
74
74
|
function compatibleConstructor(thrown, errorLike) {
|
|
75
|
-
if (isErrorInstance(errorLike))
|
|
76
|
-
|
|
77
|
-
} else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) {
|
|
78
|
-
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
79
|
-
}
|
|
75
|
+
if (isErrorInstance(errorLike)) return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
76
|
+
else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
80
77
|
return false;
|
|
81
78
|
}
|
|
82
79
|
__name(compatibleConstructor, "compatibleConstructor");
|
|
83
80
|
function compatibleMessage(thrown, errMatcher) {
|
|
84
81
|
const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
|
|
85
|
-
if (isRegExp(errMatcher))
|
|
86
|
-
|
|
87
|
-
} else if (typeof errMatcher === "string") {
|
|
88
|
-
return comparisonString.indexOf(errMatcher) !== -1;
|
|
89
|
-
}
|
|
82
|
+
if (isRegExp(errMatcher)) return errMatcher.test(comparisonString);
|
|
83
|
+
else if (typeof errMatcher === "string") return comparisonString.indexOf(errMatcher) !== -1;
|
|
90
84
|
return false;
|
|
91
85
|
}
|
|
92
86
|
__name(compatibleMessage, "compatibleMessage");
|
|
93
87
|
function getConstructorName(errorLike) {
|
|
94
88
|
let constructorName = errorLike;
|
|
95
|
-
if (isErrorInstance(errorLike))
|
|
96
|
-
|
|
97
|
-
} else if (typeof errorLike === "function") {
|
|
89
|
+
if (isErrorInstance(errorLike)) constructorName = errorLike.constructor.name;
|
|
90
|
+
else if (typeof errorLike === "function") {
|
|
98
91
|
constructorName = errorLike.name;
|
|
99
|
-
if (constructorName === "")
|
|
100
|
-
const newConstructorName = new errorLike().name;
|
|
101
|
-
constructorName = newConstructorName || constructorName;
|
|
102
|
-
}
|
|
92
|
+
if (constructorName === "") constructorName = new errorLike().name || constructorName;
|
|
103
93
|
}
|
|
104
94
|
return constructorName;
|
|
105
95
|
}
|
|
106
96
|
__name(getConstructorName, "getConstructorName");
|
|
107
97
|
function getMessage(errorLike) {
|
|
108
98
|
let msg = "";
|
|
109
|
-
if (errorLike && errorLike.message)
|
|
110
|
-
|
|
111
|
-
} else if (typeof errorLike === "string") {
|
|
112
|
-
msg = errorLike;
|
|
113
|
-
}
|
|
99
|
+
if (errorLike && errorLike.message) msg = errorLike.message;
|
|
100
|
+
else if (typeof errorLike === "string") msg = errorLike;
|
|
114
101
|
return msg;
|
|
115
102
|
}
|
|
116
103
|
__name(getMessage, "getMessage");
|
|
117
104
|
function flag(obj, key, value) {
|
|
118
105
|
let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
119
|
-
if (arguments.length === 3)
|
|
120
|
-
|
|
121
|
-
} else {
|
|
122
|
-
return flags[key];
|
|
123
|
-
}
|
|
106
|
+
if (arguments.length === 3) flags[key] = value;
|
|
107
|
+
else return flags[key];
|
|
124
108
|
}
|
|
125
109
|
__name(flag, "flag");
|
|
126
110
|
function test(obj, args) {
|
|
@@ -129,18 +113,11 @@ function test(obj, args) {
|
|
|
129
113
|
}
|
|
130
114
|
__name(test, "test");
|
|
131
115
|
function type(obj) {
|
|
132
|
-
if (typeof obj === "undefined")
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
if (obj === null) {
|
|
136
|
-
return "null";
|
|
137
|
-
}
|
|
116
|
+
if (typeof obj === "undefined") return "undefined";
|
|
117
|
+
if (obj === null) return "null";
|
|
138
118
|
const stringTag = obj[Symbol.toStringTag];
|
|
139
|
-
if (typeof stringTag === "string")
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
const type3 = Object.prototype.toString.call(obj).slice(8, -1);
|
|
143
|
-
return type3;
|
|
119
|
+
if (typeof stringTag === "string") return stringTag;
|
|
120
|
+
return Object.prototype.toString.call(obj).slice(8, -1);
|
|
144
121
|
}
|
|
145
122
|
__name(type, "type");
|
|
146
123
|
var canElideFrames = "captureStackTrace" in Error;
|
|
@@ -149,14 +126,8 @@ var _AssertionError = class _AssertionError extends Error {
|
|
|
149
126
|
super(message);
|
|
150
127
|
__publicField(this, "message");
|
|
151
128
|
this.message = message;
|
|
152
|
-
if (canElideFrames)
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
for (const key in props) {
|
|
156
|
-
if (!(key in this)) {
|
|
157
|
-
this[key] = props[key];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
129
|
+
if (canElideFrames) Error.captureStackTrace(this, ssf || _AssertionError);
|
|
130
|
+
for (const key in props) if (!(key in this)) this[key] = props[key];
|
|
160
131
|
}
|
|
161
132
|
get name() {
|
|
162
133
|
return "AssertionError";
|
|
@@ -193,15 +164,12 @@ function expectTypes(obj, types) {
|
|
|
193
164
|
"o",
|
|
194
165
|
"u"
|
|
195
166
|
].indexOf(t.charAt(0)) ? "an" : "a";
|
|
196
|
-
|
|
197
|
-
return or + art + " " + t;
|
|
167
|
+
return (types.length > 1 && index === types.length - 1 ? "or " : "") + art + " " + t;
|
|
198
168
|
}).join(", ");
|
|
199
169
|
let objType = type(obj).toLowerCase();
|
|
200
170
|
if (!types.some(function(expected) {
|
|
201
171
|
return objType === expected;
|
|
202
|
-
}))
|
|
203
|
-
throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi);
|
|
204
|
-
}
|
|
172
|
+
})) throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi);
|
|
205
173
|
}
|
|
206
174
|
__name(expectTypes, "expectTypes");
|
|
207
175
|
function getActual(obj, args) {
|
|
@@ -249,9 +217,7 @@ var styles = {
|
|
|
249
217
|
var truncator = "…";
|
|
250
218
|
function colorise(value, styleType) {
|
|
251
219
|
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
|
252
|
-
if (!color)
|
|
253
|
-
return String(value);
|
|
254
|
-
}
|
|
220
|
+
if (!color) return String(value);
|
|
255
221
|
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
|
256
222
|
}
|
|
257
223
|
__name(colorise, "colorise");
|
|
@@ -269,9 +235,7 @@ function normaliseOptions({ showHidden = false, depth = 2, colors = false, custo
|
|
|
269
235
|
inspect: inspect3,
|
|
270
236
|
stylize
|
|
271
237
|
};
|
|
272
|
-
if (options.colors)
|
|
273
|
-
options.stylize = colorise;
|
|
274
|
-
}
|
|
238
|
+
if (options.colors) options.stylize = colorise;
|
|
275
239
|
return options;
|
|
276
240
|
}
|
|
277
241
|
__name(normaliseOptions, "normaliseOptions");
|
|
@@ -283,14 +247,10 @@ function truncate(string, length, tail = truncator) {
|
|
|
283
247
|
string = String(string);
|
|
284
248
|
const tailLength = tail.length;
|
|
285
249
|
const stringLength = string.length;
|
|
286
|
-
if (tailLength > length && stringLength > tailLength)
|
|
287
|
-
return tail;
|
|
288
|
-
}
|
|
250
|
+
if (tailLength > length && stringLength > tailLength) return tail;
|
|
289
251
|
if (stringLength > length && stringLength > tailLength) {
|
|
290
252
|
let end = length - tailLength;
|
|
291
|
-
if (end > 0 && isHighSurrogate(string[end - 1]))
|
|
292
|
-
end = end - 1;
|
|
293
|
-
}
|
|
253
|
+
if (end > 0 && isHighSurrogate(string[end - 1])) end = end - 1;
|
|
294
254
|
return `${string.slice(0, end)}${tail}`;
|
|
295
255
|
}
|
|
296
256
|
return string;
|
|
@@ -313,16 +273,10 @@ function inspectList(list, options, inspectItem, separator = ", ") {
|
|
|
313
273
|
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
314
274
|
const nextLength = output.length + string.length;
|
|
315
275
|
const truncatedLength = nextLength + truncated.length;
|
|
316
|
-
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength)
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
276
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
|
|
277
|
+
if (!last && !secondToLast && truncatedLength > originalLength) break;
|
|
322
278
|
peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
|
|
323
|
-
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength)
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
279
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
|
|
326
280
|
output += string;
|
|
327
281
|
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
328
282
|
truncated = `${truncator}(${list.length - i - 1})`;
|
|
@@ -334,19 +288,14 @@ function inspectList(list, options, inspectItem, separator = ", ") {
|
|
|
334
288
|
}
|
|
335
289
|
__name(inspectList, "inspectList");
|
|
336
290
|
function quoteComplexKey(key) {
|
|
337
|
-
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/))
|
|
338
|
-
return key;
|
|
339
|
-
}
|
|
291
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
|
|
340
292
|
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
|
|
341
293
|
}
|
|
342
294
|
__name(quoteComplexKey, "quoteComplexKey");
|
|
343
295
|
function inspectProperty([key, value], options) {
|
|
344
296
|
options.truncate -= 2;
|
|
345
|
-
if (typeof key === "string")
|
|
346
|
-
|
|
347
|
-
} else if (typeof key !== "number") {
|
|
348
|
-
key = `[${options.inspect(key, options)}]`;
|
|
349
|
-
}
|
|
297
|
+
if (typeof key === "string") key = quoteComplexKey(key);
|
|
298
|
+
else if (typeof key !== "number") key = `[${options.inspect(key, options)}]`;
|
|
350
299
|
options.truncate -= key.length;
|
|
351
300
|
value = options.inspect(value, options);
|
|
352
301
|
return `${key}: ${value}`;
|
|
@@ -359,19 +308,13 @@ function inspectArray(array, options) {
|
|
|
359
308
|
const listContents = inspectList(array, options);
|
|
360
309
|
options.truncate -= listContents.length;
|
|
361
310
|
let propertyContents = "";
|
|
362
|
-
if (nonIndexProperties.length)
|
|
363
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
364
|
-
}
|
|
311
|
+
if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
365
312
|
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
366
313
|
}
|
|
367
314
|
__name(inspectArray, "inspectArray");
|
|
368
315
|
var getArrayName = /* @__PURE__ */ __name((array) => {
|
|
369
|
-
if (typeof Buffer === "function" && array instanceof Buffer)
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
if (array[Symbol.toStringTag]) {
|
|
373
|
-
return array[Symbol.toStringTag];
|
|
374
|
-
}
|
|
316
|
+
if (typeof Buffer === "function" && array instanceof Buffer) return "Buffer";
|
|
317
|
+
if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
|
|
375
318
|
return array.constructor.name;
|
|
376
319
|
}, "getArrayName");
|
|
377
320
|
function inspectTypedArray(array, options) {
|
|
@@ -390,17 +333,13 @@ function inspectTypedArray(array, options) {
|
|
|
390
333
|
output += string;
|
|
391
334
|
}
|
|
392
335
|
let propertyContents = "";
|
|
393
|
-
if (nonIndexProperties.length)
|
|
394
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
395
|
-
}
|
|
336
|
+
if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
396
337
|
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
397
338
|
}
|
|
398
339
|
__name(inspectTypedArray, "inspectTypedArray");
|
|
399
340
|
function inspectDate(dateObject, options) {
|
|
400
341
|
const stringRepresentation = dateObject.toJSON();
|
|
401
|
-
if (stringRepresentation === null)
|
|
402
|
-
return "Invalid Date";
|
|
403
|
-
}
|
|
342
|
+
if (stringRepresentation === null) return "Invalid Date";
|
|
404
343
|
const split = stringRepresentation.split("T");
|
|
405
344
|
const date = split[0];
|
|
406
345
|
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
|
@@ -409,9 +348,7 @@ __name(inspectDate, "inspectDate");
|
|
|
409
348
|
function inspectFunction(func, options) {
|
|
410
349
|
const functionType = func[Symbol.toStringTag] || "Function";
|
|
411
350
|
const name = func.name;
|
|
412
|
-
if (!name) {
|
|
413
|
-
return options.stylize(`[${functionType}]`, "special");
|
|
414
|
-
}
|
|
351
|
+
if (!name) return options.stylize(`[${functionType}]`, "special");
|
|
415
352
|
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
|
416
353
|
}
|
|
417
354
|
__name(inspectFunction, "inspectFunction");
|
|
@@ -439,18 +376,10 @@ function inspectMap(map, options) {
|
|
|
439
376
|
__name(inspectMap, "inspectMap");
|
|
440
377
|
var isNaN = Number.isNaN || ((i) => i !== i);
|
|
441
378
|
function inspectNumber(number, options) {
|
|
442
|
-
if (isNaN(number))
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if (number === Infinity)
|
|
446
|
-
return options.stylize("Infinity", "number");
|
|
447
|
-
}
|
|
448
|
-
if (number === -Infinity) {
|
|
449
|
-
return options.stylize("-Infinity", "number");
|
|
450
|
-
}
|
|
451
|
-
if (number === 0) {
|
|
452
|
-
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
453
|
-
}
|
|
379
|
+
if (isNaN(number)) return options.stylize("NaN", "number");
|
|
380
|
+
if (number === Infinity) return options.stylize("Infinity", "number");
|
|
381
|
+
if (number === -Infinity) return options.stylize("-Infinity", "number");
|
|
382
|
+
if (number === 0) return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
454
383
|
return options.stylize(truncate(String(number), options.truncate), "number");
|
|
455
384
|
}
|
|
456
385
|
__name(inspectNumber, "inspectNumber");
|
|
@@ -481,7 +410,7 @@ function inspectSet(set2, options) {
|
|
|
481
410
|
return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
|
|
482
411
|
}
|
|
483
412
|
__name(inspectSet, "inspectSet");
|
|
484
|
-
var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
413
|
+
var stringEscapeChars = /* @__PURE__ */ new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
485
414
|
var escapeCharacters = {
|
|
486
415
|
"\b": "\\b",
|
|
487
416
|
" ": "\\t",
|
|
@@ -498,53 +427,38 @@ function escape(char) {
|
|
|
498
427
|
}
|
|
499
428
|
__name(escape, "escape");
|
|
500
429
|
function inspectString(string, options) {
|
|
501
|
-
if (stringEscapeChars.test(string))
|
|
502
|
-
string = string.replace(stringEscapeChars, escape);
|
|
503
|
-
}
|
|
430
|
+
if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
|
|
504
431
|
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
|
505
432
|
}
|
|
506
433
|
__name(inspectString, "inspectString");
|
|
507
434
|
function inspectSymbol(value) {
|
|
508
|
-
if ("description" in Symbol.prototype) {
|
|
509
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
510
|
-
}
|
|
435
|
+
if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
511
436
|
return value.toString();
|
|
512
437
|
}
|
|
513
438
|
__name(inspectSymbol, "inspectSymbol");
|
|
514
|
-
var
|
|
515
|
-
var promise_default = getPromiseValue;
|
|
439
|
+
var promise_default = /* @__PURE__ */ __name(() => "Promise{…}", "getPromiseValue");
|
|
516
440
|
function inspectObject(object, options) {
|
|
517
441
|
const properties = Object.getOwnPropertyNames(object);
|
|
518
442
|
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
519
|
-
if (properties.length === 0 && symbols.length === 0) {
|
|
520
|
-
return "{}";
|
|
521
|
-
}
|
|
443
|
+
if (properties.length === 0 && symbols.length === 0) return "{}";
|
|
522
444
|
options.truncate -= 4;
|
|
523
445
|
options.seen = options.seen || [];
|
|
524
|
-
if (options.seen.includes(object))
|
|
525
|
-
return "[Circular]";
|
|
526
|
-
}
|
|
446
|
+
if (options.seen.includes(object)) return "[Circular]";
|
|
527
447
|
options.seen.push(object);
|
|
528
448
|
const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
|
|
529
449
|
const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
|
|
530
450
|
options.seen.pop();
|
|
531
451
|
let sep = "";
|
|
532
|
-
if (propertyContents && symbolContents)
|
|
533
|
-
sep = ", ";
|
|
534
|
-
}
|
|
452
|
+
if (propertyContents && symbolContents) sep = ", ";
|
|
535
453
|
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
536
454
|
}
|
|
537
455
|
__name(inspectObject, "inspectObject");
|
|
538
456
|
var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
539
457
|
function inspectClass(value, options) {
|
|
540
458
|
let name = "";
|
|
541
|
-
if (toStringTag && toStringTag in value)
|
|
542
|
-
name = value[toStringTag];
|
|
543
|
-
}
|
|
459
|
+
if (toStringTag && toStringTag in value) name = value[toStringTag];
|
|
544
460
|
name = name || value.constructor.name;
|
|
545
|
-
if (!name || name === "_class")
|
|
546
|
-
name = "<Anonymous Class>";
|
|
547
|
-
}
|
|
461
|
+
if (!name || name === "_class") name = "<Anonymous Class>";
|
|
548
462
|
options.truncate -= name.length;
|
|
549
463
|
return `${name}${inspectObject(value, options)}`;
|
|
550
464
|
}
|
|
@@ -573,17 +487,12 @@ function inspectObject2(error, options) {
|
|
|
573
487
|
const name = error.name;
|
|
574
488
|
options.truncate -= name.length;
|
|
575
489
|
let message = "";
|
|
576
|
-
if (typeof error.message === "string")
|
|
577
|
-
|
|
578
|
-
} else {
|
|
579
|
-
properties.unshift("message");
|
|
580
|
-
}
|
|
490
|
+
if (typeof error.message === "string") message = truncate(error.message, options.truncate);
|
|
491
|
+
else properties.unshift("message");
|
|
581
492
|
message = message ? `: ${message}` : "";
|
|
582
493
|
options.truncate -= message.length + 5;
|
|
583
494
|
options.seen = options.seen || [];
|
|
584
|
-
if (options.seen.includes(error))
|
|
585
|
-
return "[Circular]";
|
|
586
|
-
}
|
|
495
|
+
if (options.seen.includes(error)) return "[Circular]";
|
|
587
496
|
options.seen.push(error);
|
|
588
497
|
const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
|
|
589
498
|
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
|
@@ -591,9 +500,7 @@ function inspectObject2(error, options) {
|
|
|
591
500
|
__name(inspectObject2, "inspectObject");
|
|
592
501
|
function inspectAttribute([key, value], options) {
|
|
593
502
|
options.truncate -= 3;
|
|
594
|
-
if (!value) {
|
|
595
|
-
return `${options.stylize(String(key), "yellow")}`;
|
|
596
|
-
}
|
|
503
|
+
if (!value) return `${options.stylize(String(key), "yellow")}`;
|
|
597
504
|
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
598
505
|
}
|
|
599
506
|
__name(inspectAttribute, "inspectAttribute");
|
|
@@ -624,14 +531,11 @@ function inspectHTML(element, options) {
|
|
|
624
531
|
options.truncate -= propertyContents.length;
|
|
625
532
|
const truncate2 = options.truncate;
|
|
626
533
|
let children = inspectNodeCollection(element.children, options);
|
|
627
|
-
if (children && children.length > truncate2) {
|
|
628
|
-
children = `${truncator}(${element.children.length})`;
|
|
629
|
-
}
|
|
534
|
+
if (children && children.length > truncate2) children = `${truncator}(${element.children.length})`;
|
|
630
535
|
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
631
536
|
}
|
|
632
537
|
__name(inspectHTML, "inspectHTML");
|
|
633
|
-
var
|
|
634
|
-
var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
538
|
+
var chaiInspect = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
635
539
|
var nodeInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
636
540
|
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
637
541
|
var stringTagMap = {};
|
|
@@ -676,21 +580,11 @@ var baseTypesMap = {
|
|
|
676
580
|
NodeList: inspectNodeCollection
|
|
677
581
|
};
|
|
678
582
|
var inspectCustom = /* @__PURE__ */ __name((value, options, type3, inspectFn) => {
|
|
679
|
-
if (chaiInspect in value && typeof value[chaiInspect] === "function")
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
if ("inspect" in value && typeof value.inspect === "function") {
|
|
686
|
-
return value.inspect(options.depth, options);
|
|
687
|
-
}
|
|
688
|
-
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
|
689
|
-
return constructorMap.get(value.constructor)(value, options);
|
|
690
|
-
}
|
|
691
|
-
if (stringTagMap[type3]) {
|
|
692
|
-
return stringTagMap[type3](value, options);
|
|
693
|
-
}
|
|
583
|
+
if (chaiInspect in value && typeof value[chaiInspect] === "function") return value[chaiInspect](options);
|
|
584
|
+
if (nodeInspect in value && typeof value[nodeInspect] === "function") return value[nodeInspect](options.depth, options, inspectFn);
|
|
585
|
+
if ("inspect" in value && typeof value.inspect === "function") return value.inspect(options.depth, options);
|
|
586
|
+
if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
|
|
587
|
+
if (stringTagMap[type3]) return stringTagMap[type3](value, options);
|
|
694
588
|
return "";
|
|
695
589
|
}, "inspectCustom");
|
|
696
590
|
var toString = Object.prototype.toString;
|
|
@@ -698,12 +592,8 @@ function inspect(value, opts = {}) {
|
|
|
698
592
|
const options = normaliseOptions(opts, inspect);
|
|
699
593
|
const { customInspect } = options;
|
|
700
594
|
let type3 = value === null ? "null" : typeof value;
|
|
701
|
-
if (type3 === "object")
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
if (type3 in baseTypesMap) {
|
|
705
|
-
return baseTypesMap[type3](value, options);
|
|
706
|
-
}
|
|
595
|
+
if (type3 === "object") type3 = toString.call(value).slice(8, -1);
|
|
596
|
+
if (type3 in baseTypesMap) return baseTypesMap[type3](value, options);
|
|
707
597
|
if (customInspect && value) {
|
|
708
598
|
const output = inspectCustom(value, options, type3, inspect);
|
|
709
599
|
if (output) {
|
|
@@ -712,21 +602,13 @@ function inspect(value, opts = {}) {
|
|
|
712
602
|
}
|
|
713
603
|
}
|
|
714
604
|
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
715
|
-
if (proto === Object.prototype || proto === null)
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
|
719
|
-
return inspectHTML(value, options);
|
|
720
|
-
}
|
|
605
|
+
if (proto === Object.prototype || proto === null) return inspectObject(value, options);
|
|
606
|
+
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) return inspectHTML(value, options);
|
|
721
607
|
if ("constructor" in value) {
|
|
722
|
-
if (value.constructor !== Object)
|
|
723
|
-
return inspectClass(value, options);
|
|
724
|
-
}
|
|
725
|
-
return inspectObject(value, options);
|
|
726
|
-
}
|
|
727
|
-
if (value === Object(value)) {
|
|
608
|
+
if (value.constructor !== Object) return inspectClass(value, options);
|
|
728
609
|
return inspectObject(value, options);
|
|
729
610
|
}
|
|
611
|
+
if (value === Object(value)) return inspectObject(value, options);
|
|
730
612
|
return options.stylize(String(value), type3);
|
|
731
613
|
}
|
|
732
614
|
__name(inspect, "inspect");
|
|
@@ -744,31 +626,23 @@ var config = {
|
|
|
744
626
|
deepEqual: null
|
|
745
627
|
};
|
|
746
628
|
function inspect2(obj, showHidden, depth, colors) {
|
|
747
|
-
|
|
629
|
+
return inspect(obj, {
|
|
748
630
|
colors,
|
|
749
631
|
depth: typeof depth === "undefined" ? 2 : depth,
|
|
750
632
|
showHidden,
|
|
751
633
|
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
|
|
752
|
-
};
|
|
753
|
-
return inspect(obj, options);
|
|
634
|
+
});
|
|
754
635
|
}
|
|
755
636
|
__name(inspect2, "inspect");
|
|
756
637
|
function objDisplay(obj) {
|
|
757
638
|
let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
|
|
758
|
-
if (config.truncateThreshold && str.length >= config.truncateThreshold)
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
return "{ Object (" + kstr + ") }";
|
|
766
|
-
} else {
|
|
767
|
-
return str;
|
|
768
|
-
}
|
|
769
|
-
} else {
|
|
770
|
-
return str;
|
|
771
|
-
}
|
|
639
|
+
if (config.truncateThreshold && str.length >= config.truncateThreshold) if (type3 === "[object Function]") return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
|
|
640
|
+
else if (type3 === "[object Array]") return "[ Array(" + obj.length + ") ]";
|
|
641
|
+
else if (type3 === "[object Object]") {
|
|
642
|
+
let keys = Object.keys(obj);
|
|
643
|
+
return "{ Object (" + (keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ")) + ") }";
|
|
644
|
+
} else return str;
|
|
645
|
+
else return str;
|
|
772
646
|
}
|
|
773
647
|
__name(objDisplay, "objDisplay");
|
|
774
648
|
function getMessage2(obj, args) {
|
|
@@ -792,31 +666,17 @@ function getMessage2(obj, args) {
|
|
|
792
666
|
__name(getMessage2, "getMessage");
|
|
793
667
|
function transferFlags(assertion, object, includeAll) {
|
|
794
668
|
let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
795
|
-
if (!object.__flags)
|
|
796
|
-
object.__flags = /* @__PURE__ */ Object.create(null);
|
|
797
|
-
}
|
|
669
|
+
if (!object.__flags) object.__flags = /* @__PURE__ */ Object.create(null);
|
|
798
670
|
includeAll = arguments.length === 3 ? includeAll : true;
|
|
799
|
-
for (let flag3 in flags)
|
|
800
|
-
if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
|
|
801
|
-
object.__flags[flag3] = flags[flag3];
|
|
802
|
-
}
|
|
803
|
-
}
|
|
671
|
+
for (let flag3 in flags) if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") object.__flags[flag3] = flags[flag3];
|
|
804
672
|
}
|
|
805
673
|
__name(transferFlags, "transferFlags");
|
|
806
674
|
function type2(obj) {
|
|
807
|
-
if (typeof obj === "undefined")
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
if (obj === null) {
|
|
811
|
-
return "null";
|
|
812
|
-
}
|
|
675
|
+
if (typeof obj === "undefined") return "undefined";
|
|
676
|
+
if (obj === null) return "null";
|
|
813
677
|
const stringTag = obj[Symbol.toStringTag];
|
|
814
|
-
if (typeof stringTag === "string")
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
const sliceStart = 8;
|
|
818
|
-
const sliceEnd = -1;
|
|
819
|
-
return Object.prototype.toString.call(obj).slice(sliceStart, sliceEnd);
|
|
678
|
+
if (typeof stringTag === "string") return stringTag;
|
|
679
|
+
return Object.prototype.toString.call(obj).slice(8, -1);
|
|
820
680
|
}
|
|
821
681
|
__name(type2, "type");
|
|
822
682
|
function FakeMap() {
|
|
@@ -828,37 +688,28 @@ FakeMap.prototype = {
|
|
|
828
688
|
return key[this._key];
|
|
829
689
|
}, "get"),
|
|
830
690
|
set: /* @__PURE__ */ __name(function set(key, value) {
|
|
831
|
-
if (Object.isExtensible(key)) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
});
|
|
836
|
-
}
|
|
691
|
+
if (Object.isExtensible(key)) Object.defineProperty(key, this._key, {
|
|
692
|
+
value,
|
|
693
|
+
configurable: true
|
|
694
|
+
});
|
|
837
695
|
}, "set")
|
|
838
696
|
};
|
|
839
697
|
var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
|
|
840
698
|
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
|
|
841
|
-
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand))
|
|
842
|
-
return null;
|
|
843
|
-
}
|
|
699
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return null;
|
|
844
700
|
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
845
701
|
if (leftHandMap) {
|
|
846
702
|
var result = leftHandMap.get(rightHandOperand);
|
|
847
|
-
if (typeof result === "boolean")
|
|
848
|
-
return result;
|
|
849
|
-
}
|
|
703
|
+
if (typeof result === "boolean") return result;
|
|
850
704
|
}
|
|
851
705
|
return null;
|
|
852
706
|
}
|
|
853
707
|
__name(memoizeCompare, "memoizeCompare");
|
|
854
708
|
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
|
855
|
-
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand))
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
709
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return;
|
|
858
710
|
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
859
|
-
if (leftHandMap)
|
|
860
|
-
|
|
861
|
-
} else {
|
|
711
|
+
if (leftHandMap) leftHandMap.set(rightHandOperand, result);
|
|
712
|
+
else {
|
|
862
713
|
leftHandMap = new MemoizeMap();
|
|
863
714
|
leftHandMap.set(rightHandOperand, result);
|
|
864
715
|
memoizeMap.set(leftHandOperand, leftHandMap);
|
|
@@ -867,26 +718,16 @@ function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
|
|
867
718
|
__name(memoizeSet, "memoizeSet");
|
|
868
719
|
var deep_eql_default = deepEqual;
|
|
869
720
|
function deepEqual(leftHandOperand, rightHandOperand, options) {
|
|
870
|
-
if (options && options.comparator)
|
|
871
|
-
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
872
|
-
}
|
|
721
|
+
if (options && options.comparator) return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
873
722
|
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
874
|
-
if (simpleResult !== null)
|
|
875
|
-
return simpleResult;
|
|
876
|
-
}
|
|
723
|
+
if (simpleResult !== null) return simpleResult;
|
|
877
724
|
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
878
725
|
}
|
|
879
726
|
__name(deepEqual, "deepEqual");
|
|
880
727
|
function simpleEqual(leftHandOperand, rightHandOperand) {
|
|
881
|
-
if (leftHandOperand === rightHandOperand)
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) {
|
|
885
|
-
return true;
|
|
886
|
-
}
|
|
887
|
-
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
888
|
-
return false;
|
|
889
|
-
}
|
|
728
|
+
if (leftHandOperand === rightHandOperand) return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
|
|
729
|
+
if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) return true;
|
|
730
|
+
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return false;
|
|
890
731
|
return null;
|
|
891
732
|
}
|
|
892
733
|
__name(simpleEqual, "simpleEqual");
|
|
@@ -895,13 +736,9 @@ function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
|
|
895
736
|
options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
|
|
896
737
|
var comparator = options && options.comparator;
|
|
897
738
|
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
|
|
898
|
-
if (memoizeResultLeft !== null)
|
|
899
|
-
return memoizeResultLeft;
|
|
900
|
-
}
|
|
739
|
+
if (memoizeResultLeft !== null) return memoizeResultLeft;
|
|
901
740
|
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
|
|
902
|
-
if (memoizeResultRight !== null)
|
|
903
|
-
return memoizeResultRight;
|
|
904
|
-
}
|
|
741
|
+
if (memoizeResultRight !== null) return memoizeResultRight;
|
|
905
742
|
if (comparator) {
|
|
906
743
|
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
|
|
907
744
|
if (comparatorResult === false || comparatorResult === true) {
|
|
@@ -909,9 +746,7 @@ function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
|
|
909
746
|
return comparatorResult;
|
|
910
747
|
}
|
|
911
748
|
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
912
|
-
if (simpleResult !== null)
|
|
913
|
-
return simpleResult;
|
|
914
|
-
}
|
|
749
|
+
if (simpleResult !== null) return simpleResult;
|
|
915
750
|
}
|
|
916
751
|
var leftHandType = type2(leftHandOperand);
|
|
917
752
|
if (leftHandType !== type2(rightHandOperand)) {
|
|
@@ -977,12 +812,8 @@ function regexpEqual(leftHandOperand, rightHandOperand) {
|
|
|
977
812
|
__name(regexpEqual, "regexpEqual");
|
|
978
813
|
function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
|
979
814
|
try {
|
|
980
|
-
if (leftHandOperand.size !== rightHandOperand.size)
|
|
981
|
-
|
|
982
|
-
}
|
|
983
|
-
if (leftHandOperand.size === 0) {
|
|
984
|
-
return true;
|
|
985
|
-
}
|
|
815
|
+
if (leftHandOperand.size !== rightHandOperand.size) return false;
|
|
816
|
+
if (leftHandOperand.size === 0) return true;
|
|
986
817
|
} catch (sizeError) {
|
|
987
818
|
return false;
|
|
988
819
|
}
|
|
@@ -999,18 +830,10 @@ function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
|
|
999
830
|
__name(entriesEqual, "entriesEqual");
|
|
1000
831
|
function iterableEqual(leftHandOperand, rightHandOperand, options) {
|
|
1001
832
|
var length = leftHandOperand.length;
|
|
1002
|
-
if (length !== rightHandOperand.length)
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
if (length === 0) {
|
|
1006
|
-
return true;
|
|
1007
|
-
}
|
|
833
|
+
if (length !== rightHandOperand.length) return false;
|
|
834
|
+
if (length === 0) return true;
|
|
1008
835
|
var index = -1;
|
|
1009
|
-
while (++index < length)
|
|
1010
|
-
if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
|
|
1011
|
-
return false;
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
836
|
+
while (++index < length) if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) return false;
|
|
1014
837
|
return true;
|
|
1015
838
|
}
|
|
1016
839
|
__name(iterableEqual, "iterableEqual");
|
|
@@ -1023,12 +846,10 @@ function hasIteratorFunction(target) {
|
|
|
1023
846
|
}
|
|
1024
847
|
__name(hasIteratorFunction, "hasIteratorFunction");
|
|
1025
848
|
function getIteratorEntries(target) {
|
|
1026
|
-
if (hasIteratorFunction(target)) {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
return [];
|
|
1031
|
-
}
|
|
849
|
+
if (hasIteratorFunction(target)) try {
|
|
850
|
+
return getGeneratorEntries(target[Symbol.iterator]());
|
|
851
|
+
} catch (iteratorError) {
|
|
852
|
+
return [];
|
|
1032
853
|
}
|
|
1033
854
|
return [];
|
|
1034
855
|
}
|
|
@@ -1045,9 +866,7 @@ function getGeneratorEntries(generator) {
|
|
|
1045
866
|
__name(getGeneratorEntries, "getGeneratorEntries");
|
|
1046
867
|
function getEnumerableKeys(target) {
|
|
1047
868
|
var keys = [];
|
|
1048
|
-
for (var key in target)
|
|
1049
|
-
keys.push(key);
|
|
1050
|
-
}
|
|
869
|
+
for (var key in target) keys.push(key);
|
|
1051
870
|
return keys;
|
|
1052
871
|
}
|
|
1053
872
|
__name(getEnumerableKeys, "getEnumerableKeys");
|
|
@@ -1056,23 +875,15 @@ function getEnumerableSymbols(target) {
|
|
|
1056
875
|
var allKeys = Object.getOwnPropertySymbols(target);
|
|
1057
876
|
for (var i = 0; i < allKeys.length; i += 1) {
|
|
1058
877
|
var key = allKeys[i];
|
|
1059
|
-
if (Object.getOwnPropertyDescriptor(target, key).enumerable)
|
|
1060
|
-
keys.push(key);
|
|
1061
|
-
}
|
|
878
|
+
if (Object.getOwnPropertyDescriptor(target, key).enumerable) keys.push(key);
|
|
1062
879
|
}
|
|
1063
880
|
return keys;
|
|
1064
881
|
}
|
|
1065
882
|
__name(getEnumerableSymbols, "getEnumerableSymbols");
|
|
1066
883
|
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
|
1067
884
|
var length = keys.length;
|
|
1068
|
-
if (length === 0)
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
for (var i = 0; i < length; i += 1) {
|
|
1072
|
-
if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
|
|
1073
|
-
return false;
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
885
|
+
if (length === 0) return true;
|
|
886
|
+
for (var i = 0; i < length; i += 1) if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) return false;
|
|
1076
887
|
return true;
|
|
1077
888
|
}
|
|
1078
889
|
__name(keysEqual, "keysEqual");
|
|
@@ -1084,9 +895,7 @@ function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
|
1084
895
|
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
|
1085
896
|
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
|
1086
897
|
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
|
|
1087
|
-
if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false)
|
|
1088
|
-
return false;
|
|
1089
|
-
}
|
|
898
|
+
if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) return false;
|
|
1090
899
|
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
|
|
1091
900
|
}
|
|
1092
901
|
var leftHandEntries = getIteratorEntries(leftHandOperand);
|
|
@@ -1096,9 +905,7 @@ function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
|
1096
905
|
rightHandEntries.sort();
|
|
1097
906
|
return iterableEqual(leftHandEntries, rightHandEntries, options);
|
|
1098
907
|
}
|
|
1099
|
-
if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0)
|
|
1100
|
-
return true;
|
|
1101
|
-
}
|
|
908
|
+
if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) return true;
|
|
1102
909
|
return false;
|
|
1103
910
|
}
|
|
1104
911
|
__name(objectEqual, "objectEqual");
|
|
@@ -1108,35 +915,23 @@ function isPrimitive(value) {
|
|
|
1108
915
|
__name(isPrimitive, "isPrimitive");
|
|
1109
916
|
function mapSymbols(arr) {
|
|
1110
917
|
return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
|
|
1111
|
-
if (typeof entry === "symbol")
|
|
1112
|
-
return entry.toString();
|
|
1113
|
-
}
|
|
918
|
+
if (typeof entry === "symbol") return entry.toString();
|
|
1114
919
|
return entry;
|
|
1115
920
|
}, "mapSymbol"));
|
|
1116
921
|
}
|
|
1117
922
|
__name(mapSymbols, "mapSymbols");
|
|
1118
923
|
function hasProperty(obj, name) {
|
|
1119
|
-
if (typeof obj === "undefined" || obj === null)
|
|
1120
|
-
return false;
|
|
1121
|
-
}
|
|
924
|
+
if (typeof obj === "undefined" || obj === null) return false;
|
|
1122
925
|
return name in Object(obj);
|
|
1123
926
|
}
|
|
1124
927
|
__name(hasProperty, "hasProperty");
|
|
1125
928
|
function parsePath(path) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
if (value === "constructor" || value === "__proto__" || value === "prototype") {
|
|
1130
|
-
return {};
|
|
1131
|
-
}
|
|
1132
|
-
const regexp = /^\[(\d+)\]$/;
|
|
1133
|
-
const mArr = regexp.exec(value);
|
|
929
|
+
return path.replace(/([^\\])\[/g, "$1.[").match(/(\\\.|[^.]+?)+/g).map((value) => {
|
|
930
|
+
if (value === "constructor" || value === "__proto__" || value === "prototype") return {};
|
|
931
|
+
const mArr = /^\[(\d+)\]$/.exec(value);
|
|
1134
932
|
let parsed = null;
|
|
1135
|
-
if (mArr) {
|
|
1136
|
-
|
|
1137
|
-
} else {
|
|
1138
|
-
parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1139
|
-
}
|
|
933
|
+
if (mArr) parsed = { i: parseFloat(mArr[1]) };
|
|
934
|
+
else parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1140
935
|
return parsed;
|
|
1141
936
|
});
|
|
1142
937
|
}
|
|
@@ -1148,14 +943,9 @@ function internalGetPathValue(obj, parsed, pathDepth) {
|
|
|
1148
943
|
for (let i = 0; i < pathDepth; i++) {
|
|
1149
944
|
const part = parsed[i];
|
|
1150
945
|
if (temporaryValue) {
|
|
1151
|
-
if (typeof part.p === "undefined")
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
temporaryValue = temporaryValue[part.p];
|
|
1155
|
-
}
|
|
1156
|
-
if (i === pathDepth - 1) {
|
|
1157
|
-
res = temporaryValue;
|
|
1158
|
-
}
|
|
946
|
+
if (typeof part.p === "undefined") temporaryValue = temporaryValue[part.i];
|
|
947
|
+
else temporaryValue = temporaryValue[part.p];
|
|
948
|
+
if (i === pathDepth - 1) res = temporaryValue;
|
|
1159
949
|
}
|
|
1160
950
|
}
|
|
1161
951
|
return res;
|
|
@@ -1304,16 +1094,13 @@ var _Assertion = class _Assertion {
|
|
|
1304
1094
|
if (true !== config.showDiff) showDiff = false;
|
|
1305
1095
|
if (!ok) {
|
|
1306
1096
|
msg = getMessage2(this, arguments);
|
|
1307
|
-
const actual = getActual(this, arguments);
|
|
1308
1097
|
const assertionErrorObjectProperties = {
|
|
1309
|
-
actual,
|
|
1098
|
+
actual: getActual(this, arguments),
|
|
1310
1099
|
expected,
|
|
1311
1100
|
showDiff
|
|
1312
1101
|
};
|
|
1313
1102
|
const operator = getOperator(this, arguments);
|
|
1314
|
-
if (operator)
|
|
1315
|
-
assertionErrorObjectProperties.operator = operator;
|
|
1316
|
-
}
|
|
1103
|
+
if (operator) assertionErrorObjectProperties.operator = operator;
|
|
1317
1104
|
throw new AssertionError(msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi"));
|
|
1318
1105
|
}
|
|
1319
1106
|
}
|
|
@@ -1354,9 +1141,7 @@ function addProperty(ctx, name, getter) {
|
|
|
1354
1141
|
getter = getter === void 0 ? function() {} : getter;
|
|
1355
1142
|
Object.defineProperty(ctx, name, {
|
|
1356
1143
|
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
1357
|
-
if (!isProxyEnabled() && !flag(this, "lockSsfi"))
|
|
1358
|
-
flag(this, "ssfi", propertyGetter);
|
|
1359
|
-
}
|
|
1144
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", propertyGetter);
|
|
1360
1145
|
let result = getter.call(this);
|
|
1361
1146
|
if (result !== void 0) return result;
|
|
1362
1147
|
let newAssertion = new Assertion();
|
|
@@ -1372,9 +1157,7 @@ var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
|
|
|
1372
1157
|
function addLengthGuard(fn, assertionName, isChainable) {
|
|
1373
1158
|
if (!fnLengthDesc.configurable) return fn;
|
|
1374
1159
|
Object.defineProperty(fn, "length", { get: /* @__PURE__ */ __name(function() {
|
|
1375
|
-
if (isChainable)
|
|
1376
|
-
throw Error("Invalid Chai property: " + assertionName + ".length. Due to a compatibility issue, \"length\" cannot directly follow \"" + assertionName + "\". Use \"" + assertionName + ".lengthOf\" instead.");
|
|
1377
|
-
}
|
|
1160
|
+
if (isChainable) throw Error("Invalid Chai property: " + assertionName + ".length. Due to a compatibility issue, \"length\" cannot directly follow \"" + assertionName + "\". Use \"" + assertionName + ".lengthOf\" instead.");
|
|
1378
1161
|
throw Error("Invalid Chai property: " + assertionName + ".length. See docs for proper usage of \"" + assertionName + "\".");
|
|
1379
1162
|
}, "get") });
|
|
1380
1163
|
return fn;
|
|
@@ -1383,9 +1166,7 @@ __name(addLengthGuard, "addLengthGuard");
|
|
|
1383
1166
|
function getProperties(object) {
|
|
1384
1167
|
let result = Object.getOwnPropertyNames(object);
|
|
1385
1168
|
function addProperty2(property) {
|
|
1386
|
-
if (result.indexOf(property) === -1)
|
|
1387
|
-
result.push(property);
|
|
1388
|
-
}
|
|
1169
|
+
if (result.indexOf(property) === -1) result.push(property);
|
|
1389
1170
|
}
|
|
1390
1171
|
__name(addProperty2, "addProperty");
|
|
1391
1172
|
let proto = Object.getPrototypeOf(object);
|
|
@@ -1406,9 +1187,7 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1406
1187
|
if (!isProxyEnabled()) return obj;
|
|
1407
1188
|
return new Proxy(obj, { get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1408
1189
|
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
1409
|
-
if (nonChainableMethodName)
|
|
1410
|
-
throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + ". See docs for proper usage of \"" + nonChainableMethodName + "\".");
|
|
1411
|
-
}
|
|
1190
|
+
if (nonChainableMethodName) throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + ". See docs for proper usage of \"" + nonChainableMethodName + "\".");
|
|
1412
1191
|
let suggestion = null;
|
|
1413
1192
|
let suggestionDistance = 4;
|
|
1414
1193
|
getProperties(target).forEach(function(prop) {
|
|
@@ -1420,31 +1199,22 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1420
1199
|
}
|
|
1421
1200
|
}
|
|
1422
1201
|
});
|
|
1423
|
-
if (suggestion !== null)
|
|
1424
|
-
|
|
1425
|
-
} else {
|
|
1426
|
-
throw Error("Invalid Chai property: " + property);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) {
|
|
1430
|
-
flag(target, "ssfi", proxyGetter);
|
|
1202
|
+
if (suggestion !== null) throw Error("Invalid Chai property: " + property + ". Did you mean \"" + suggestion + "\"?");
|
|
1203
|
+
else throw Error("Invalid Chai property: " + property);
|
|
1431
1204
|
}
|
|
1205
|
+
if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) flag(target, "ssfi", proxyGetter);
|
|
1432
1206
|
return Reflect.get(target, property);
|
|
1433
1207
|
}, "proxyGetter") });
|
|
1434
1208
|
}
|
|
1435
1209
|
__name(proxify, "proxify");
|
|
1436
1210
|
function stringDistanceCapped(strA, strB, cap) {
|
|
1437
|
-
if (Math.abs(strA.length - strB.length) >= cap)
|
|
1438
|
-
return cap;
|
|
1439
|
-
}
|
|
1211
|
+
if (Math.abs(strA.length - strB.length) >= cap) return cap;
|
|
1440
1212
|
let memo = [];
|
|
1441
1213
|
for (let i = 0; i <= strA.length; i++) {
|
|
1442
1214
|
memo[i] = Array(strB.length + 1).fill(0);
|
|
1443
1215
|
memo[i][0] = i;
|
|
1444
1216
|
}
|
|
1445
|
-
for (let j = 0; j < strB.length; j++)
|
|
1446
|
-
memo[0][j] = j;
|
|
1447
|
-
}
|
|
1217
|
+
for (let j = 0; j < strB.length; j++) memo[0][j] = j;
|
|
1448
1218
|
for (let i = 1; i <= strA.length; i++) {
|
|
1449
1219
|
let ch = strA.charCodeAt(i - 1);
|
|
1450
1220
|
for (let j = 1; j <= strB.length; j++) {
|
|
@@ -1460,9 +1230,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1460
1230
|
__name(stringDistanceCapped, "stringDistanceCapped");
|
|
1461
1231
|
function addMethod(ctx, name, method) {
|
|
1462
1232
|
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1463
|
-
if (!flag(this, "lockSsfi"))
|
|
1464
|
-
flag(this, "ssfi", methodWrapper);
|
|
1465
|
-
}
|
|
1233
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", methodWrapper);
|
|
1466
1234
|
let result = method.apply(this, arguments);
|
|
1467
1235
|
if (result !== void 0) return result;
|
|
1468
1236
|
let newAssertion = new Assertion();
|
|
@@ -1479,16 +1247,12 @@ function overwriteProperty(ctx, name, getter) {
|
|
|
1479
1247
|
if (_get && "function" === typeof _get.get) _super = _get.get;
|
|
1480
1248
|
Object.defineProperty(ctx, name, {
|
|
1481
1249
|
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1482
|
-
if (!isProxyEnabled() && !flag(this, "lockSsfi"))
|
|
1483
|
-
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1484
|
-
}
|
|
1250
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", overwritingPropertyGetter);
|
|
1485
1251
|
let origLockSsfi = flag(this, "lockSsfi");
|
|
1486
1252
|
flag(this, "lockSsfi", true);
|
|
1487
1253
|
let result = getter(_super).call(this);
|
|
1488
1254
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1489
|
-
if (result !== void 0)
|
|
1490
|
-
return result;
|
|
1491
|
-
}
|
|
1255
|
+
if (result !== void 0) return result;
|
|
1492
1256
|
let newAssertion = new Assertion();
|
|
1493
1257
|
transferFlags(this, newAssertion);
|
|
1494
1258
|
return newAssertion;
|
|
@@ -1503,16 +1267,12 @@ function overwriteMethod(ctx, name, method) {
|
|
|
1503
1267
|
}, "_super");
|
|
1504
1268
|
if (_method && "function" === typeof _method) _super = _method;
|
|
1505
1269
|
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1506
|
-
if (!flag(this, "lockSsfi"))
|
|
1507
|
-
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1508
|
-
}
|
|
1270
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", overwritingMethodWrapper);
|
|
1509
1271
|
let origLockSsfi = flag(this, "lockSsfi");
|
|
1510
1272
|
flag(this, "lockSsfi", true);
|
|
1511
1273
|
let result = method(_super).apply(this, arguments);
|
|
1512
1274
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1513
|
-
if (result !== void 0)
|
|
1514
|
-
return result;
|
|
1515
|
-
}
|
|
1275
|
+
if (result !== void 0) return result;
|
|
1516
1276
|
let newAssertion = new Assertion();
|
|
1517
1277
|
transferFlags(this, newAssertion);
|
|
1518
1278
|
return newAssertion;
|
|
@@ -1539,28 +1299,20 @@ var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent extend
|
|
|
1539
1299
|
__name(_PluginAddChainableMethodEvent, "PluginAddChainableMethodEvent");
|
|
1540
1300
|
var PluginAddChainableMethodEvent = _PluginAddChainableMethodEvent;
|
|
1541
1301
|
function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
1542
|
-
if (typeof chainingBehavior !== "function") {
|
|
1543
|
-
chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
|
|
1544
|
-
}
|
|
1302
|
+
if (typeof chainingBehavior !== "function") chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
|
|
1545
1303
|
let chainableBehavior = {
|
|
1546
1304
|
method,
|
|
1547
1305
|
chainingBehavior
|
|
1548
1306
|
};
|
|
1549
|
-
if (!ctx.__methods) {
|
|
1550
|
-
ctx.__methods = {};
|
|
1551
|
-
}
|
|
1307
|
+
if (!ctx.__methods) ctx.__methods = {};
|
|
1552
1308
|
ctx.__methods[name] = chainableBehavior;
|
|
1553
1309
|
Object.defineProperty(ctx, name, {
|
|
1554
1310
|
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1555
1311
|
chainableBehavior.chainingBehavior.call(this);
|
|
1556
1312
|
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1557
|
-
if (!flag(this, "lockSsfi"))
|
|
1558
|
-
flag(this, "ssfi", chainableMethodWrapper);
|
|
1559
|
-
}
|
|
1313
|
+
if (!flag(this, "lockSsfi")) flag(this, "ssfi", chainableMethodWrapper);
|
|
1560
1314
|
let result = chainableBehavior.method.apply(this, arguments);
|
|
1561
|
-
if (result !== void 0)
|
|
1562
|
-
return result;
|
|
1563
|
-
}
|
|
1315
|
+
if (result !== void 0) return result;
|
|
1564
1316
|
let newAssertion = new Assertion();
|
|
1565
1317
|
transferFlags(this, newAssertion);
|
|
1566
1318
|
return newAssertion;
|
|
@@ -1571,16 +1323,11 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1571
1323
|
prototype.call = call;
|
|
1572
1324
|
prototype.apply = apply;
|
|
1573
1325
|
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1574
|
-
} else {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1580
|
-
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1581
|
-
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1326
|
+
} else Object.getOwnPropertyNames(ctx).forEach(function(asserterName) {
|
|
1327
|
+
if (excludeNames.indexOf(asserterName) !== -1) return;
|
|
1328
|
+
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1329
|
+
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1330
|
+
});
|
|
1584
1331
|
transferFlags(this, chainableMethodWrapper);
|
|
1585
1332
|
return proxify(chainableMethodWrapper);
|
|
1586
1333
|
}, "chainableMethodGetter"),
|
|
@@ -1594,9 +1341,7 @@ function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1594
1341
|
let _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
1595
1342
|
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
1596
1343
|
let result = chainingBehavior(_chainingBehavior).call(this);
|
|
1597
|
-
if (result !== void 0)
|
|
1598
|
-
return result;
|
|
1599
|
-
}
|
|
1344
|
+
if (result !== void 0) return result;
|
|
1600
1345
|
let newAssertion = new Assertion();
|
|
1601
1346
|
transferFlags(this, newAssertion);
|
|
1602
1347
|
return newAssertion;
|
|
@@ -1604,9 +1349,7 @@ function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1604
1349
|
let _method = chainableBehavior.method;
|
|
1605
1350
|
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
1606
1351
|
let result = method(_method).apply(this, arguments);
|
|
1607
|
-
if (result !== void 0)
|
|
1608
|
-
return result;
|
|
1609
|
-
}
|
|
1352
|
+
if (result !== void 0) return result;
|
|
1610
1353
|
let newAssertion = new Assertion();
|
|
1611
1354
|
transferFlags(this, newAssertion);
|
|
1612
1355
|
return newAssertion;
|
|
@@ -1631,12 +1374,11 @@ __name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
|
1631
1374
|
var isNaN2 = Number.isNaN;
|
|
1632
1375
|
function isObjectType(obj) {
|
|
1633
1376
|
let objectType = type(obj);
|
|
1634
|
-
|
|
1377
|
+
return [
|
|
1635
1378
|
"Array",
|
|
1636
1379
|
"Object",
|
|
1637
1380
|
"Function"
|
|
1638
|
-
];
|
|
1639
|
-
return objectTypes.indexOf(objectType) !== -1;
|
|
1381
|
+
].indexOf(objectType) !== -1;
|
|
1640
1382
|
}
|
|
1641
1383
|
__name(isObjectType, "isObjectType");
|
|
1642
1384
|
function getOperator(obj, args) {
|
|
@@ -1644,21 +1386,13 @@ function getOperator(obj, args) {
|
|
|
1644
1386
|
let negate = flag(obj, "negate");
|
|
1645
1387
|
let expected = args[3];
|
|
1646
1388
|
let msg = negate ? args[2] : args[1];
|
|
1647
|
-
if (operator)
|
|
1648
|
-
return operator;
|
|
1649
|
-
}
|
|
1389
|
+
if (operator) return operator;
|
|
1650
1390
|
if (typeof msg === "function") msg = msg();
|
|
1651
1391
|
msg = msg || "";
|
|
1652
|
-
if (!msg)
|
|
1653
|
-
|
|
1654
|
-
}
|
|
1655
|
-
if (/\shave\s/.test(msg)) {
|
|
1656
|
-
return void 0;
|
|
1657
|
-
}
|
|
1392
|
+
if (!msg) return;
|
|
1393
|
+
if (/\shave\s/.test(msg)) return;
|
|
1658
1394
|
let isObject = isObjectType(expected);
|
|
1659
|
-
if (/\snot\s/.test(msg))
|
|
1660
|
-
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
1661
|
-
}
|
|
1395
|
+
if (/\snot\s/.test(msg)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
1662
1396
|
return isObject ? "deepStrictEqual" : "strictEqual";
|
|
1663
1397
|
}
|
|
1664
1398
|
__name(getOperator, "getOperator");
|
|
@@ -1741,11 +1475,8 @@ function an(type3, msg) {
|
|
|
1741
1475
|
"u"
|
|
1742
1476
|
].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
1743
1477
|
const detectedType = type(obj).toLowerCase();
|
|
1744
|
-
if (functionTypes["function"].includes(type3)) {
|
|
1745
|
-
|
|
1746
|
-
} else {
|
|
1747
|
-
this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
1748
|
-
}
|
|
1478
|
+
if (functionTypes["function"].includes(type3)) this.assert(functionTypes[type3].includes(detectedType), "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
1479
|
+
else this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
1749
1480
|
}
|
|
1750
1481
|
__name(an, "an");
|
|
1751
1482
|
Assertion.addChainableMethod("an", an);
|
|
@@ -1768,9 +1499,7 @@ function include(val, msg) {
|
|
|
1768
1499
|
included = obj.indexOf(val) !== -1;
|
|
1769
1500
|
break;
|
|
1770
1501
|
case "weakset":
|
|
1771
|
-
if (isDeep)
|
|
1772
|
-
throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", void 0, ssfi);
|
|
1773
|
-
}
|
|
1502
|
+
if (isDeep) throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", void 0, ssfi);
|
|
1774
1503
|
included = obj.has(val);
|
|
1775
1504
|
break;
|
|
1776
1505
|
case "map":
|
|
@@ -1779,27 +1508,19 @@ function include(val, msg) {
|
|
|
1779
1508
|
});
|
|
1780
1509
|
break;
|
|
1781
1510
|
case "set":
|
|
1782
|
-
if (isDeep) {
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
} else {
|
|
1787
|
-
included = obj.has(val);
|
|
1788
|
-
}
|
|
1511
|
+
if (isDeep) obj.forEach(function(item) {
|
|
1512
|
+
included = included || isEql(item, val);
|
|
1513
|
+
});
|
|
1514
|
+
else included = obj.has(val);
|
|
1789
1515
|
break;
|
|
1790
1516
|
case "array":
|
|
1791
|
-
if (isDeep) {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
} else {
|
|
1796
|
-
included = obj.indexOf(val) !== -1;
|
|
1797
|
-
}
|
|
1517
|
+
if (isDeep) included = obj.some(function(item) {
|
|
1518
|
+
return isEql(item, val);
|
|
1519
|
+
});
|
|
1520
|
+
else included = obj.indexOf(val) !== -1;
|
|
1798
1521
|
break;
|
|
1799
1522
|
default: {
|
|
1800
|
-
if (val !== Object(val))
|
|
1801
|
-
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);
|
|
1802
|
-
}
|
|
1523
|
+
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);
|
|
1803
1524
|
let props = Object.keys(val);
|
|
1804
1525
|
let firstErr = null;
|
|
1805
1526
|
let numErrs = 0;
|
|
@@ -1814,16 +1535,12 @@ function include(val, msg) {
|
|
|
1814
1535
|
try {
|
|
1815
1536
|
propAssertion.property(prop, val[prop]);
|
|
1816
1537
|
} catch (err) {
|
|
1817
|
-
if (!check_error_exports.compatibleConstructor(err, AssertionError))
|
|
1818
|
-
throw err;
|
|
1819
|
-
}
|
|
1538
|
+
if (!check_error_exports.compatibleConstructor(err, AssertionError)) throw err;
|
|
1820
1539
|
if (firstErr === null) firstErr = err;
|
|
1821
1540
|
numErrs++;
|
|
1822
1541
|
}
|
|
1823
1542
|
}, this);
|
|
1824
|
-
if (negate && props.length > 1 && numErrs === props.length)
|
|
1825
|
-
throw firstErr;
|
|
1826
|
-
}
|
|
1543
|
+
if (negate && props.length > 1 && numErrs === props.length) throw firstErr;
|
|
1827
1544
|
return;
|
|
1828
1545
|
}
|
|
1829
1546
|
}
|
|
@@ -1857,9 +1574,7 @@ Assertion.addProperty("callable", function() {
|
|
|
1857
1574
|
"GeneratorFunction",
|
|
1858
1575
|
"AsyncGeneratorFunction"
|
|
1859
1576
|
].includes(type(val));
|
|
1860
|
-
if (isCallable && negate || !isCallable && !negate)
|
|
1861
|
-
throw new AssertionError(assertionMessage, void 0, ssfi);
|
|
1862
|
-
}
|
|
1577
|
+
if (isCallable && negate || !isCallable && !negate) throw new AssertionError(assertionMessage, void 0, ssfi);
|
|
1863
1578
|
});
|
|
1864
1579
|
Assertion.addProperty("false", function() {
|
|
1865
1580
|
this.assert(false === flag2(this, "object"), "expected #{this} to be false", "expected #{this} to be true", flag2(this, "negate") ? true : false);
|
|
@@ -1894,20 +1609,15 @@ Assertion.addProperty("empty", function() {
|
|
|
1894
1609
|
break;
|
|
1895
1610
|
case "weakmap":
|
|
1896
1611
|
case "weakset": throw new AssertionError(flagMsg + ".empty was passed a weak collection", void 0, ssfi);
|
|
1897
|
-
case "function":
|
|
1898
|
-
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
1899
|
-
throw new AssertionError(msg.trim(), void 0, ssfi);
|
|
1900
|
-
}
|
|
1612
|
+
case "function": throw new AssertionError((flagMsg + ".empty was passed a function " + getName(val)).trim(), void 0, ssfi);
|
|
1901
1613
|
default:
|
|
1902
|
-
if (val !== Object(val))
|
|
1903
|
-
throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), void 0, ssfi);
|
|
1904
|
-
}
|
|
1614
|
+
if (val !== Object(val)) throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), void 0, ssfi);
|
|
1905
1615
|
itemsCount = Object.keys(val).length;
|
|
1906
1616
|
}
|
|
1907
1617
|
this.assert(0 === itemsCount, "expected #{this} to be empty", "expected #{this} not to be empty");
|
|
1908
1618
|
});
|
|
1909
1619
|
function checkArguments() {
|
|
1910
|
-
let
|
|
1620
|
+
let type3 = type(flag2(this, "object"));
|
|
1911
1621
|
this.assert("Arguments" === type3, "expected #{this} to be arguments but got " + type3, "expected #{this} to not be arguments");
|
|
1912
1622
|
}
|
|
1913
1623
|
__name(checkArguments, "checkArguments");
|
|
@@ -1921,9 +1631,7 @@ function assertEqual(val, msg) {
|
|
|
1921
1631
|
flag2(this, "lockSsfi", true);
|
|
1922
1632
|
this.eql(val);
|
|
1923
1633
|
flag2(this, "lockSsfi", prevLockSsfi);
|
|
1924
|
-
} else {
|
|
1925
|
-
this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
|
|
1926
|
-
}
|
|
1634
|
+
} else this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
|
|
1927
1635
|
}
|
|
1928
1636
|
__name(assertEqual, "assertEqual");
|
|
1929
1637
|
Assertion.addMethod("equal", assertEqual);
|
|
@@ -1940,14 +1648,10 @@ Assertion.addMethod("eqls", assertEql);
|
|
|
1940
1648
|
function assertAbove(n, msg) {
|
|
1941
1649
|
if (msg) flag2(this, "message", msg);
|
|
1942
1650
|
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();
|
|
1943
|
-
if (doLength && objType !== "map" && objType !== "set")
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
if (!doLength && objType
|
|
1947
|
-
throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
|
|
1948
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
1949
|
-
throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
|
|
1950
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1651
|
+
if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
1652
|
+
if (!doLength && objType === "date" && nType !== "date") throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
|
|
1653
|
+
else if (!isNumeric(n) && (doLength || isNumeric(obj))) throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
|
|
1654
|
+
else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1951
1655
|
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
1952
1656
|
throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
|
|
1953
1657
|
}
|
|
@@ -1956,13 +1660,9 @@ function assertAbove(n, msg) {
|
|
|
1956
1660
|
if (objType === "map" || objType === "set") {
|
|
1957
1661
|
descriptor = "size";
|
|
1958
1662
|
itemsCount = obj.size;
|
|
1959
|
-
} else
|
|
1960
|
-
itemsCount = obj.length;
|
|
1961
|
-
}
|
|
1663
|
+
} else itemsCount = obj.length;
|
|
1962
1664
|
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);
|
|
1963
|
-
} else {
|
|
1964
|
-
this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
|
|
1965
|
-
}
|
|
1665
|
+
} else this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
|
|
1966
1666
|
}
|
|
1967
1667
|
__name(assertAbove, "assertAbove");
|
|
1968
1668
|
Assertion.addMethod("above", assertAbove);
|
|
@@ -1971,34 +1671,22 @@ Assertion.addMethod("greaterThan", assertAbove);
|
|
|
1971
1671
|
function assertLeast(n, msg) {
|
|
1972
1672
|
if (msg) flag2(this, "message", msg);
|
|
1973
1673
|
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;
|
|
1974
|
-
if (doLength && objType !== "map" && objType !== "set")
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
if (!doLength && objType
|
|
1978
|
-
errorMessage = msgPrefix + "the argument to least must be a date";
|
|
1979
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
1980
|
-
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
1981
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1674
|
+
if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
1675
|
+
if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to least must be a date";
|
|
1676
|
+
else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to least must be a number";
|
|
1677
|
+
else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1982
1678
|
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
1983
1679
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
1984
|
-
} else
|
|
1985
|
-
|
|
1986
|
-
}
|
|
1987
|
-
if (shouldThrow) {
|
|
1988
|
-
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
1989
|
-
}
|
|
1680
|
+
} else shouldThrow = false;
|
|
1681
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
1990
1682
|
if (doLength) {
|
|
1991
1683
|
let descriptor = "length", itemsCount;
|
|
1992
1684
|
if (objType === "map" || objType === "set") {
|
|
1993
1685
|
descriptor = "size";
|
|
1994
1686
|
itemsCount = obj.size;
|
|
1995
|
-
} else
|
|
1996
|
-
itemsCount = obj.length;
|
|
1997
|
-
}
|
|
1687
|
+
} else itemsCount = obj.length;
|
|
1998
1688
|
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);
|
|
1999
|
-
} else {
|
|
2000
|
-
this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
|
|
2001
|
-
}
|
|
1689
|
+
} else this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
|
|
2002
1690
|
}
|
|
2003
1691
|
__name(assertLeast, "assertLeast");
|
|
2004
1692
|
Assertion.addMethod("least", assertLeast);
|
|
@@ -2007,34 +1695,22 @@ Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
|
2007
1695
|
function assertBelow(n, msg) {
|
|
2008
1696
|
if (msg) flag2(this, "message", msg);
|
|
2009
1697
|
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;
|
|
2010
|
-
if (doLength && objType !== "map" && objType !== "set")
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
if (!doLength && objType
|
|
2014
|
-
errorMessage = msgPrefix + "the argument to below must be a date";
|
|
2015
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2016
|
-
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2017
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1698
|
+
if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
1699
|
+
if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to below must be a date";
|
|
1700
|
+
else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to below must be a number";
|
|
1701
|
+
else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2018
1702
|
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2019
1703
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2020
|
-
} else
|
|
2021
|
-
|
|
2022
|
-
}
|
|
2023
|
-
if (shouldThrow) {
|
|
2024
|
-
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2025
|
-
}
|
|
1704
|
+
} else shouldThrow = false;
|
|
1705
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2026
1706
|
if (doLength) {
|
|
2027
1707
|
let descriptor = "length", itemsCount;
|
|
2028
1708
|
if (objType === "map" || objType === "set") {
|
|
2029
1709
|
descriptor = "size";
|
|
2030
1710
|
itemsCount = obj.size;
|
|
2031
|
-
} else
|
|
2032
|
-
itemsCount = obj.length;
|
|
2033
|
-
}
|
|
1711
|
+
} else itemsCount = obj.length;
|
|
2034
1712
|
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);
|
|
2035
|
-
} else {
|
|
2036
|
-
this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
|
|
2037
|
-
}
|
|
1713
|
+
} else this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
|
|
2038
1714
|
}
|
|
2039
1715
|
__name(assertBelow, "assertBelow");
|
|
2040
1716
|
Assertion.addMethod("below", assertBelow);
|
|
@@ -2043,34 +1719,22 @@ Assertion.addMethod("lessThan", assertBelow);
|
|
|
2043
1719
|
function assertMost(n, msg) {
|
|
2044
1720
|
if (msg) flag2(this, "message", msg);
|
|
2045
1721
|
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;
|
|
2046
|
-
if (doLength && objType !== "map" && objType !== "set")
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
if (!doLength && objType
|
|
2050
|
-
errorMessage = msgPrefix + "the argument to most must be a date";
|
|
2051
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2052
|
-
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2053
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1722
|
+
if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
1723
|
+
if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to most must be a date";
|
|
1724
|
+
else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to most must be a number";
|
|
1725
|
+
else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2054
1726
|
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2055
1727
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2056
|
-
} else
|
|
2057
|
-
|
|
2058
|
-
}
|
|
2059
|
-
if (shouldThrow) {
|
|
2060
|
-
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2061
|
-
}
|
|
1728
|
+
} else shouldThrow = false;
|
|
1729
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2062
1730
|
if (doLength) {
|
|
2063
1731
|
let descriptor = "length", itemsCount;
|
|
2064
1732
|
if (objType === "map" || objType === "set") {
|
|
2065
1733
|
descriptor = "size";
|
|
2066
1734
|
itemsCount = obj.size;
|
|
2067
|
-
} else
|
|
2068
|
-
itemsCount = obj.length;
|
|
2069
|
-
}
|
|
1735
|
+
} else itemsCount = obj.length;
|
|
2070
1736
|
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);
|
|
2071
|
-
} else {
|
|
2072
|
-
this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
|
|
2073
|
-
}
|
|
1737
|
+
} else this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
|
|
2074
1738
|
}
|
|
2075
1739
|
__name(assertMost, "assertMost");
|
|
2076
1740
|
Assertion.addMethod("most", assertMost);
|
|
@@ -2079,34 +1743,22 @@ Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
|
2079
1743
|
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2080
1744
|
if (msg) flag2(this, "message", msg);
|
|
2081
1745
|
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
2082
|
-
if (doLength && objType !== "map" && objType !== "set")
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
if (!doLength && objType
|
|
2086
|
-
errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
2087
|
-
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2088
|
-
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2089
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
1746
|
+
if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
1747
|
+
if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
1748
|
+
else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
1749
|
+
else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2090
1750
|
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2091
1751
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2092
|
-
} else
|
|
2093
|
-
|
|
2094
|
-
}
|
|
2095
|
-
if (shouldThrow) {
|
|
2096
|
-
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2097
|
-
}
|
|
1752
|
+
} else shouldThrow = false;
|
|
1753
|
+
if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2098
1754
|
if (doLength) {
|
|
2099
1755
|
let descriptor = "length", itemsCount;
|
|
2100
1756
|
if (objType === "map" || objType === "set") {
|
|
2101
1757
|
descriptor = "size";
|
|
2102
1758
|
itemsCount = obj.size;
|
|
2103
|
-
} else
|
|
2104
|
-
itemsCount = obj.length;
|
|
2105
|
-
}
|
|
1759
|
+
} else itemsCount = obj.length;
|
|
2106
1760
|
this.assert(itemsCount >= start && itemsCount <= finish, "expected #{this} to have a " + descriptor + " within " + range, "expected #{this} to not have a " + descriptor + " within " + range);
|
|
2107
|
-
} else {
|
|
2108
|
-
this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
|
|
2109
|
-
}
|
|
1761
|
+
} else this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
|
|
2110
1762
|
});
|
|
2111
1763
|
function assertInstanceOf(constructor, msg) {
|
|
2112
1764
|
if (msg) flag2(this, "message", msg);
|
|
@@ -2124,9 +1776,7 @@ function assertInstanceOf(constructor, msg) {
|
|
|
2124
1776
|
throw err;
|
|
2125
1777
|
}
|
|
2126
1778
|
let name = getName(constructor);
|
|
2127
|
-
if (name == null)
|
|
2128
|
-
name = "an unnamed constructor";
|
|
2129
|
-
}
|
|
1779
|
+
if (name == null) name = "an unnamed constructor";
|
|
2130
1780
|
this.assert(isInstanceOf, "expected #{this} to be an instance of " + name, "expected #{this} to not be an instance of " + name);
|
|
2131
1781
|
}
|
|
2132
1782
|
__name(assertInstanceOf, "assertInstanceOf");
|
|
@@ -2137,20 +1787,10 @@ function assertProperty(name, val, msg) {
|
|
|
2137
1787
|
let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2138
1788
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2139
1789
|
if (isNested) {
|
|
2140
|
-
if (nameType !== "string")
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") {
|
|
2145
|
-
throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", void 0, ssfi);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
if (isNested && isOwn) {
|
|
2149
|
-
throw new AssertionError(flagMsg + "The \"nested\" and \"own\" flags cannot be combined.", void 0, ssfi);
|
|
2150
|
-
}
|
|
2151
|
-
if (obj === null || obj === void 0) {
|
|
2152
|
-
throw new AssertionError(flagMsg + "Target cannot be null or undefined.", void 0, ssfi);
|
|
2153
|
-
}
|
|
1790
|
+
if (nameType !== "string") throw new AssertionError(flagMsg + "the argument to property must be a string when using nested syntax", void 0, ssfi);
|
|
1791
|
+
} else if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", void 0, ssfi);
|
|
1792
|
+
if (isNested && isOwn) throw new AssertionError(flagMsg + "The \"nested\" and \"own\" flags cannot be combined.", void 0, ssfi);
|
|
1793
|
+
if (obj === null || obj === void 0) throw new AssertionError(flagMsg + "Target cannot be null or undefined.", void 0, ssfi);
|
|
2154
1794
|
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;
|
|
2155
1795
|
let descriptor = "";
|
|
2156
1796
|
if (isDeep) descriptor += "deep ";
|
|
@@ -2161,12 +1801,8 @@ function assertProperty(name, val, msg) {
|
|
|
2161
1801
|
if (isOwn) hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
|
|
2162
1802
|
else if (isNested) hasProperty2 = pathInfo.exists;
|
|
2163
1803
|
else hasProperty2 = hasProperty(obj, name);
|
|
2164
|
-
if (!negate || arguments.length === 1) {
|
|
2165
|
-
|
|
2166
|
-
}
|
|
2167
|
-
if (arguments.length > 1) {
|
|
2168
|
-
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);
|
|
2169
|
-
}
|
|
1804
|
+
if (!negate || arguments.length === 1) this.assert(hasProperty2, "expected #{this} to have " + descriptor + inspect2(name), "expected #{this} to not have " + descriptor + inspect2(name));
|
|
1805
|
+
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);
|
|
2170
1806
|
flag2(this, "object", value);
|
|
2171
1807
|
}
|
|
2172
1808
|
__name(assertProperty, "assertProperty");
|
|
@@ -2187,11 +1823,8 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
|
2187
1823
|
let obj = flag2(this, "object");
|
|
2188
1824
|
let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
2189
1825
|
let eql = flag2(this, "eql");
|
|
2190
|
-
if (actualDescriptor && descriptor) {
|
|
2191
|
-
|
|
2192
|
-
} else {
|
|
2193
|
-
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));
|
|
2194
|
-
}
|
|
1826
|
+
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);
|
|
1827
|
+
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));
|
|
2195
1828
|
flag2(this, "object", actualDescriptor);
|
|
2196
1829
|
}
|
|
2197
1830
|
__name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
|
|
@@ -2229,8 +1862,8 @@ Assertion.addMethod("match", assertMatch);
|
|
|
2229
1862
|
Assertion.addMethod("matches", assertMatch);
|
|
2230
1863
|
Assertion.addMethod("string", function(str, msg) {
|
|
2231
1864
|
if (msg) flag2(this, "message", msg);
|
|
2232
|
-
let obj = flag2(this, "object")
|
|
2233
|
-
new Assertion(obj,
|
|
1865
|
+
let obj = flag2(this, "object");
|
|
1866
|
+
new Assertion(obj, flag2(this, "message"), flag2(this, "ssfi"), true).is.a("string");
|
|
2234
1867
|
this.assert(~obj.indexOf(str), "expected #{this} to contain " + inspect2(str), "expected #{this} to not contain " + inspect2(str));
|
|
2235
1868
|
});
|
|
2236
1869
|
function assertKeys(keys) {
|
|
@@ -2243,21 +1876,15 @@ function assertKeys(keys) {
|
|
|
2243
1876
|
obj.forEach(function(val, key) {
|
|
2244
1877
|
actual.push(key);
|
|
2245
1878
|
});
|
|
2246
|
-
if (keysType !== "Array")
|
|
2247
|
-
keys = Array.prototype.slice.call(arguments);
|
|
2248
|
-
}
|
|
1879
|
+
if (keysType !== "Array") keys = Array.prototype.slice.call(arguments);
|
|
2249
1880
|
} else {
|
|
2250
1881
|
actual = getOwnEnumerableProperties(obj);
|
|
2251
1882
|
switch (keysType) {
|
|
2252
1883
|
case "Array":
|
|
2253
|
-
if (arguments.length > 1)
|
|
2254
|
-
throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
2255
|
-
}
|
|
1884
|
+
if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
2256
1885
|
break;
|
|
2257
1886
|
case "Object":
|
|
2258
|
-
if (arguments.length > 1)
|
|
2259
|
-
throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
2260
|
-
}
|
|
1887
|
+
if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
|
|
2261
1888
|
keys = Object.keys(keys);
|
|
2262
1889
|
break;
|
|
2263
1890
|
default: keys = Array.prototype.slice.call(arguments);
|
|
@@ -2266,44 +1893,30 @@ function assertKeys(keys) {
|
|
|
2266
1893
|
return typeof val === "symbol" ? val : String(val);
|
|
2267
1894
|
});
|
|
2268
1895
|
}
|
|
2269
|
-
if (!keys.length)
|
|
2270
|
-
throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
2271
|
-
}
|
|
1896
|
+
if (!keys.length) throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
2272
1897
|
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2273
|
-
if (!any && !all)
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
ok = expected.some(function(expectedKey) {
|
|
2278
|
-
return actual.some(function(actualKey) {
|
|
2279
|
-
return isEql(expectedKey, actualKey);
|
|
2280
|
-
});
|
|
1898
|
+
if (!any && !all) all = true;
|
|
1899
|
+
if (any) ok = expected.some(function(expectedKey) {
|
|
1900
|
+
return actual.some(function(actualKey) {
|
|
1901
|
+
return isEql(expectedKey, actualKey);
|
|
2281
1902
|
});
|
|
2282
|
-
}
|
|
1903
|
+
});
|
|
2283
1904
|
if (all) {
|
|
2284
1905
|
ok = expected.every(function(expectedKey) {
|
|
2285
1906
|
return actual.some(function(actualKey) {
|
|
2286
1907
|
return isEql(expectedKey, actualKey);
|
|
2287
1908
|
});
|
|
2288
1909
|
});
|
|
2289
|
-
if (!flag2(this, "contains"))
|
|
2290
|
-
ok = ok && keys.length == actual.length;
|
|
2291
|
-
}
|
|
1910
|
+
if (!flag2(this, "contains")) ok = ok && keys.length == actual.length;
|
|
2292
1911
|
}
|
|
2293
1912
|
if (len > 1) {
|
|
2294
1913
|
keys = keys.map(function(key) {
|
|
2295
1914
|
return inspect2(key);
|
|
2296
1915
|
});
|
|
2297
1916
|
let last = keys.pop();
|
|
2298
|
-
if (all)
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
if (any) {
|
|
2302
|
-
str = keys.join(", ") + ", or " + last;
|
|
2303
|
-
}
|
|
2304
|
-
} else {
|
|
2305
|
-
str = inspect2(keys[0]);
|
|
2306
|
-
}
|
|
1917
|
+
if (all) str = keys.join(", ") + ", and " + last;
|
|
1918
|
+
if (any) str = keys.join(", ") + ", or " + last;
|
|
1919
|
+
} else str = inspect2(keys[0]);
|
|
2307
1920
|
str = (len > 1 ? "keys " : "key ") + str;
|
|
2308
1921
|
str = (flag2(this, "contains") ? "contain " : "have ") + str;
|
|
2309
1922
|
this.assert(ok, "expected #{this} to " + deepStr + str, "expected #{this} to not " + deepStr + str, expected.slice(0).sort(compareByInspect), actual.sort(compareByInspect), true);
|
|
@@ -2333,60 +1946,31 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2333
1946
|
let errMsgMatcherFail = false;
|
|
2334
1947
|
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
2335
1948
|
let errorLikeString = "an error";
|
|
2336
|
-
if (errorLike instanceof Error) {
|
|
2337
|
-
|
|
2338
|
-
} else if (errorLike) {
|
|
2339
|
-
errorLikeString = check_error_exports.getConstructorName(errorLike);
|
|
2340
|
-
}
|
|
1949
|
+
if (errorLike instanceof Error) errorLikeString = "#{exp}";
|
|
1950
|
+
else if (errorLike) errorLikeString = check_error_exports.getConstructorName(errorLike);
|
|
2341
1951
|
let actual = caughtErr;
|
|
2342
|
-
if (caughtErr instanceof Error)
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
actual = caughtErr;
|
|
2346
|
-
}
|
|
2347
|
-
try {
|
|
2348
|
-
actual = check_error_exports.getConstructorName(caughtErr);
|
|
2349
|
-
} catch (_err) {}
|
|
2350
|
-
}
|
|
1952
|
+
if (caughtErr instanceof Error) actual = caughtErr.toString();
|
|
1953
|
+
else if (typeof caughtErr === "string") actual = caughtErr;
|
|
1954
|
+
else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) try {
|
|
1955
|
+
actual = check_error_exports.getConstructorName(caughtErr);
|
|
1956
|
+
} catch (_err) {}
|
|
2351
1957
|
this.assert(errorWasThrown, "expected #{this} to throw " + errorLikeString, "expected #{this} to not throw an error but #{act} was thrown", errorLike && errorLike.toString(), actual);
|
|
2352
1958
|
}
|
|
2353
1959
|
if (errorLike && caughtErr) {
|
|
2354
1960
|
if (errorLike instanceof Error) {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
if (everyArgIsDefined && negate) {
|
|
2358
|
-
errorLikeFail = true;
|
|
2359
|
-
} else {
|
|
2360
|
-
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());
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
let isCompatibleConstructor = check_error_exports.compatibleConstructor(caughtErr, errorLike);
|
|
2365
|
-
if (isCompatibleConstructor === negate) {
|
|
2366
|
-
if (everyArgIsDefined && negate) {
|
|
2367
|
-
errorLikeFail = true;
|
|
2368
|
-
} else {
|
|
2369
|
-
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));
|
|
2370
|
-
}
|
|
1961
|
+
if (check_error_exports.compatibleInstance(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
|
|
1962
|
+
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());
|
|
2371
1963
|
}
|
|
1964
|
+
if (check_error_exports.compatibleConstructor(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
|
|
1965
|
+
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));
|
|
2372
1966
|
}
|
|
2373
1967
|
if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
|
|
2374
1968
|
let placeholder = "including";
|
|
2375
|
-
if (isRegExp2(errMsgMatcher))
|
|
2376
|
-
|
|
2377
|
-
}
|
|
2378
|
-
let isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
|
|
2379
|
-
if (isCompatibleMessage === negate) {
|
|
2380
|
-
if (everyArgIsDefined && negate) {
|
|
2381
|
-
errMsgMatcherFail = true;
|
|
2382
|
-
} else {
|
|
2383
|
-
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));
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
if (errorLikeFail && errMsgMatcherFail) {
|
|
2388
|
-
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));
|
|
1969
|
+
if (isRegExp2(errMsgMatcher)) placeholder = "matching";
|
|
1970
|
+
if (check_error_exports.compatibleMessage(caughtErr, errMsgMatcher) === negate) if (everyArgIsDefined && negate) errMsgMatcherFail = true;
|
|
1971
|
+
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));
|
|
2389
1972
|
}
|
|
1973
|
+
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));
|
|
2390
1974
|
flag2(this, "object", caughtErr);
|
|
2391
1975
|
}
|
|
2392
1976
|
__name(assertThrows, "assertThrows");
|
|
@@ -2406,8 +1990,7 @@ Assertion.addProperty("itself", function() {
|
|
|
2406
1990
|
});
|
|
2407
1991
|
function satisfy(matcher, msg) {
|
|
2408
1992
|
if (msg) flag2(this, "message", msg);
|
|
2409
|
-
let
|
|
2410
|
-
let result = matcher(obj);
|
|
1993
|
+
let result = matcher(flag2(this, "object"));
|
|
2411
1994
|
this.assert(result, "expected #{this} to satisfy " + objDisplay(matcher), "expected #{this} to not satisfy" + objDisplay(matcher), flag2(this, "negate") ? false : true, result);
|
|
2412
1995
|
}
|
|
2413
1996
|
__name(satisfy, "satisfy");
|
|
@@ -2418,14 +2001,10 @@ function closeTo(expected, delta, msg) {
|
|
|
2418
2001
|
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2419
2002
|
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
2420
2003
|
let message = "A `delta` value is required for `closeTo`";
|
|
2421
|
-
if (delta == void 0) {
|
|
2422
|
-
throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
2423
|
-
}
|
|
2004
|
+
if (delta == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
2424
2005
|
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
2425
2006
|
message = "A `expected` value is required for `closeTo`";
|
|
2426
|
-
if (expected == void 0) {
|
|
2427
|
-
throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
2428
|
-
}
|
|
2007
|
+
if (expected == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
|
|
2429
2008
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
2430
2009
|
const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
|
|
2431
2010
|
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
@@ -2486,19 +2065,13 @@ function oneOf(list, msg) {
|
|
|
2486
2065
|
if (msg) flag2(this, "message", msg);
|
|
2487
2066
|
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");
|
|
2488
2067
|
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
2489
|
-
if (contains) {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
return eql(expected, possibility);
|
|
2497
|
-
}), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
|
|
2498
|
-
} else {
|
|
2499
|
-
this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2068
|
+
if (contains) this.assert(list.some(function(possibility) {
|
|
2069
|
+
return expected.indexOf(possibility) > -1;
|
|
2070
|
+
}), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
|
|
2071
|
+
else if (isDeep) this.assert(list.some(function(possibility) {
|
|
2072
|
+
return eql(expected, possibility);
|
|
2073
|
+
}), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
|
|
2074
|
+
else this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
|
|
2502
2075
|
}
|
|
2503
2076
|
__name(oneOf, "oneOf");
|
|
2504
2077
|
Assertion.addMethod("oneOf", oneOf);
|
|
@@ -2587,11 +2160,8 @@ function assertDelta(delta, msg) {
|
|
|
2587
2160
|
let behavior = flag2(this, "deltaBehavior");
|
|
2588
2161
|
let realDelta = flag2(this, "realDelta");
|
|
2589
2162
|
let expression;
|
|
2590
|
-
if (behavior === "change")
|
|
2591
|
-
|
|
2592
|
-
} else {
|
|
2593
|
-
expression = realDelta === Math.abs(delta);
|
|
2594
|
-
}
|
|
2163
|
+
if (behavior === "change") expression = Math.abs(final - initial) === Math.abs(delta);
|
|
2164
|
+
else expression = realDelta === Math.abs(delta);
|
|
2595
2165
|
this.assert(expression, "expected " + msgObj + " to " + behavior + " by " + delta, "expected " + msgObj + " to not " + behavior + " by " + delta);
|
|
2596
2166
|
}
|
|
2597
2167
|
__name(assertDelta, "assertDelta");
|
|
@@ -2616,44 +2186,25 @@ Assertion.addProperty("finite", function(_msg) {
|
|
|
2616
2186
|
this.assert(typeof obj === "number" && isFinite(obj), "expected #{this} to be a finite number", "expected #{this} to not be a finite number");
|
|
2617
2187
|
});
|
|
2618
2188
|
function compareSubset(expected, actual) {
|
|
2619
|
-
if (expected === actual)
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
if (
|
|
2623
|
-
return false;
|
|
2624
|
-
}
|
|
2625
|
-
if (typeof expected !== "object" || expected === null) {
|
|
2626
|
-
return expected === actual;
|
|
2627
|
-
}
|
|
2628
|
-
if (!actual) {
|
|
2629
|
-
return false;
|
|
2630
|
-
}
|
|
2189
|
+
if (expected === actual) return true;
|
|
2190
|
+
if (typeof actual !== typeof expected) return false;
|
|
2191
|
+
if (typeof expected !== "object" || expected === null) return expected === actual;
|
|
2192
|
+
if (!actual) return false;
|
|
2631
2193
|
if (Array.isArray(expected)) {
|
|
2632
|
-
if (!Array.isArray(actual))
|
|
2633
|
-
return false;
|
|
2634
|
-
}
|
|
2194
|
+
if (!Array.isArray(actual)) return false;
|
|
2635
2195
|
return expected.every(function(exp) {
|
|
2636
2196
|
return actual.some(function(act) {
|
|
2637
2197
|
return compareSubset(exp, act);
|
|
2638
2198
|
});
|
|
2639
2199
|
});
|
|
2640
2200
|
}
|
|
2641
|
-
if (expected instanceof Date)
|
|
2642
|
-
|
|
2643
|
-
return expected.getTime() === actual.getTime();
|
|
2644
|
-
} else {
|
|
2645
|
-
return false;
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2201
|
+
if (expected instanceof Date) if (actual instanceof Date) return expected.getTime() === actual.getTime();
|
|
2202
|
+
else return false;
|
|
2648
2203
|
return Object.keys(expected).every(function(key) {
|
|
2649
2204
|
let expectedValue = expected[key];
|
|
2650
2205
|
let actualValue = actual[key];
|
|
2651
|
-
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null)
|
|
2652
|
-
|
|
2653
|
-
}
|
|
2654
|
-
if (typeof expectedValue === "function") {
|
|
2655
|
-
return expectedValue(actualValue);
|
|
2656
|
-
}
|
|
2206
|
+
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) return compareSubset(expectedValue, actualValue);
|
|
2207
|
+
if (typeof expectedValue === "function") return expectedValue(actualValue);
|
|
2657
2208
|
return actualValue === expectedValue;
|
|
2658
2209
|
});
|
|
2659
2210
|
}
|
|
@@ -2686,9 +2237,7 @@ __export(should_exports, {
|
|
|
2686
2237
|
});
|
|
2687
2238
|
function loadShould() {
|
|
2688
2239
|
function shouldGetter() {
|
|
2689
|
-
if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt)
|
|
2690
|
-
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
2691
|
-
}
|
|
2240
|
+
if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) return new Assertion(this.valueOf(), null, shouldGetter);
|
|
2692
2241
|
return new Assertion(this, null, shouldGetter);
|
|
2693
2242
|
}
|
|
2694
2243
|
__name(shouldGetter, "shouldGetter");
|
|
@@ -2746,8 +2295,7 @@ __name(loadShould, "loadShould");
|
|
|
2746
2295
|
var should = loadShould;
|
|
2747
2296
|
var Should = loadShould;
|
|
2748
2297
|
function assert(express, errmsg) {
|
|
2749
|
-
|
|
2750
|
-
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
2298
|
+
new Assertion(null, null, assert, true).assert(express, errmsg, "[ negation message unavailable ]");
|
|
2751
2299
|
}
|
|
2752
2300
|
__name(assert, "assert");
|
|
2753
2301
|
assert.fail = function(actual, expected, message, operator) {
|
|
@@ -3027,8 +2575,7 @@ assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
|
3027
2575
|
errMsgMatcher = errorLike;
|
|
3028
2576
|
errorLike = null;
|
|
3029
2577
|
}
|
|
3030
|
-
|
|
3031
|
-
return flag(assertErr, "object");
|
|
2578
|
+
return flag(new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher), "object");
|
|
3032
2579
|
};
|
|
3033
2580
|
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
3034
2581
|
if ("string" === typeof errorLike || errorLike instanceof RegExp) {
|
|
@@ -3254,9 +2801,7 @@ assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
|
3254
2801
|
new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
|
|
3255
2802
|
};
|
|
3256
2803
|
assert.ifError = function(val) {
|
|
3257
|
-
if (val)
|
|
3258
|
-
throw val;
|
|
3259
|
-
}
|
|
2804
|
+
if (val) throw val;
|
|
3260
2805
|
};
|
|
3261
2806
|
assert.isExtensible = function(obj, msg) {
|
|
3262
2807
|
new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
|
|
@@ -3288,7 +2833,7 @@ assert.containsSubset = function(val, exp, msg) {
|
|
|
3288
2833
|
assert.doesNotContainSubset = function(val, exp, msg) {
|
|
3289
2834
|
new Assertion(val, msg).to.not.containSubset(exp);
|
|
3290
2835
|
};
|
|
3291
|
-
|
|
2836
|
+
for (const [name, as] of [
|
|
3292
2837
|
["isOk", "ok"],
|
|
3293
2838
|
["isNotOk", "notOk"],
|
|
3294
2839
|
["throws", "throw"],
|
|
@@ -3304,10 +2849,7 @@ var aliases = [
|
|
|
3304
2849
|
["isCallable", "isFunction"],
|
|
3305
2850
|
["isNotCallable", "isNotFunction"],
|
|
3306
2851
|
["containsSubset", "containSubset"]
|
|
3307
|
-
];
|
|
3308
|
-
for (const [name, as] of aliases) {
|
|
3309
|
-
assert[as] = assert[name];
|
|
3310
|
-
}
|
|
2852
|
+
]) assert[as] = assert[name];
|
|
3311
2853
|
var used = [];
|
|
3312
2854
|
function use(fn) {
|
|
3313
2855
|
const exports = {
|
|
@@ -3572,6 +3114,5 @@ references to blow the stack.
|
|
|
3572
3114
|
* @return {Boolean} result
|
|
3573
3115
|
*)
|
|
3574
3116
|
*/
|
|
3575
|
-
|
|
3576
3117
|
//#endregion
|
|
3577
|
-
export { Assertion, AssertionError, Should, assert, config, expect, should, use, utils_exports as util };
|
|
3118
|
+
export { Assertion, AssertionError, Should, assert, config, expect, should, use, utils_exports as util };
|