tutuca 0.9.71 → 0.9.72
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/chai.js +3389 -0
- package/dist/immutable.js +4333 -0
- package/dist/tutuca-cli.js +111 -1
- package/dist/tutuca-dev.ext.js +86 -3392
- package/package.json +9 -1
- package/skill/tutuca/cli.md +5 -5
- package/skill/tutuca/core.md +11 -0
- package/skill/tutuca/testing.md +16 -10
package/dist/tutuca-dev.ext.js
CHANGED
|
@@ -40,7 +40,7 @@ var __export = (target, all) => {
|
|
|
40
40
|
var exports_dev = {};
|
|
41
41
|
__export(exports_dev, {
|
|
42
42
|
tutuca: () => tutuca,
|
|
43
|
-
test: () =>
|
|
43
|
+
test: () => test3,
|
|
44
44
|
suggestionToMessage: () => suggestionToMessage,
|
|
45
45
|
runTests: () => runTests,
|
|
46
46
|
reportTestReportToConsole: () => reportTestReportToConsole,
|
|
@@ -122,3313 +122,7 @@ __export(exports_dev, {
|
|
|
122
122
|
ALT_HANDLER_NOT_REFERENCED: () => ALT_HANDLER_NOT_REFERENCED,
|
|
123
123
|
ALT_HANDLER_NOT_DEFINED: () => ALT_HANDLER_NOT_DEFINED
|
|
124
124
|
});
|
|
125
|
-
|
|
126
|
-
// node_modules/chai/index.js
|
|
127
|
-
var exports_chai = {};
|
|
128
|
-
__export(exports_chai, {
|
|
129
|
-
util: () => utils_exports,
|
|
130
|
-
use: () => use,
|
|
131
|
-
should: () => should,
|
|
132
|
-
expect: () => expect,
|
|
133
|
-
config: () => config,
|
|
134
|
-
assert: () => assert,
|
|
135
|
-
Should: () => Should,
|
|
136
|
-
AssertionError: () => AssertionError,
|
|
137
|
-
Assertion: () => Assertion
|
|
138
|
-
});
|
|
139
|
-
var __defProp2 = Object.defineProperty;
|
|
140
|
-
var __defNormalProp = (obj, key, value) => (key in obj) ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
141
|
-
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
|
|
142
|
-
var __export2 = (target, all) => {
|
|
143
|
-
for (var name in all)
|
|
144
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
145
|
-
};
|
|
146
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
147
|
-
var utils_exports = {};
|
|
148
|
-
__export2(utils_exports, {
|
|
149
|
-
addChainableMethod: () => addChainableMethod,
|
|
150
|
-
addLengthGuard: () => addLengthGuard,
|
|
151
|
-
addMethod: () => addMethod,
|
|
152
|
-
addProperty: () => addProperty,
|
|
153
|
-
checkError: () => check_error_exports,
|
|
154
|
-
compareByInspect: () => compareByInspect,
|
|
155
|
-
eql: () => deep_eql_default,
|
|
156
|
-
events: () => events,
|
|
157
|
-
expectTypes: () => expectTypes,
|
|
158
|
-
flag: () => flag,
|
|
159
|
-
getActual: () => getActual,
|
|
160
|
-
getMessage: () => getMessage2,
|
|
161
|
-
getName: () => getName,
|
|
162
|
-
getOperator: () => getOperator,
|
|
163
|
-
getOwnEnumerableProperties: () => getOwnEnumerableProperties,
|
|
164
|
-
getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
|
|
165
|
-
getPathInfo: () => getPathInfo,
|
|
166
|
-
hasProperty: () => hasProperty,
|
|
167
|
-
inspect: () => inspect2,
|
|
168
|
-
isNaN: () => isNaN2,
|
|
169
|
-
isNumeric: () => isNumeric,
|
|
170
|
-
isProxyEnabled: () => isProxyEnabled,
|
|
171
|
-
isRegExp: () => isRegExp2,
|
|
172
|
-
objDisplay: () => objDisplay,
|
|
173
|
-
overwriteChainableMethod: () => overwriteChainableMethod,
|
|
174
|
-
overwriteMethod: () => overwriteMethod,
|
|
175
|
-
overwriteProperty: () => overwriteProperty,
|
|
176
|
-
proxify: () => proxify,
|
|
177
|
-
test: () => test,
|
|
178
|
-
transferFlags: () => transferFlags,
|
|
179
|
-
type: () => type
|
|
180
|
-
});
|
|
181
|
-
var check_error_exports = {};
|
|
182
|
-
__export2(check_error_exports, {
|
|
183
|
-
compatibleConstructor: () => compatibleConstructor,
|
|
184
|
-
compatibleInstance: () => compatibleInstance,
|
|
185
|
-
compatibleMessage: () => compatibleMessage,
|
|
186
|
-
getConstructorName: () => getConstructorName,
|
|
187
|
-
getMessage: () => getMessage
|
|
188
|
-
});
|
|
189
|
-
function isErrorInstance(obj) {
|
|
190
|
-
return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
|
|
191
|
-
}
|
|
192
|
-
__name(isErrorInstance, "isErrorInstance");
|
|
193
|
-
function isRegExp(obj) {
|
|
194
|
-
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
195
|
-
}
|
|
196
|
-
__name(isRegExp, "isRegExp");
|
|
197
|
-
function compatibleInstance(thrown, errorLike) {
|
|
198
|
-
return isErrorInstance(errorLike) && thrown === errorLike;
|
|
199
|
-
}
|
|
200
|
-
__name(compatibleInstance, "compatibleInstance");
|
|
201
|
-
function compatibleConstructor(thrown, errorLike) {
|
|
202
|
-
if (isErrorInstance(errorLike)) {
|
|
203
|
-
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
204
|
-
} else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) {
|
|
205
|
-
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
206
|
-
}
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
__name(compatibleConstructor, "compatibleConstructor");
|
|
210
|
-
function compatibleMessage(thrown, errMatcher) {
|
|
211
|
-
const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
|
|
212
|
-
if (isRegExp(errMatcher)) {
|
|
213
|
-
return errMatcher.test(comparisonString);
|
|
214
|
-
} else if (typeof errMatcher === "string") {
|
|
215
|
-
return comparisonString.indexOf(errMatcher) !== -1;
|
|
216
|
-
}
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
__name(compatibleMessage, "compatibleMessage");
|
|
220
|
-
function getConstructorName(errorLike) {
|
|
221
|
-
let constructorName = errorLike;
|
|
222
|
-
if (isErrorInstance(errorLike)) {
|
|
223
|
-
constructorName = errorLike.constructor.name;
|
|
224
|
-
} else if (typeof errorLike === "function") {
|
|
225
|
-
constructorName = errorLike.name;
|
|
226
|
-
if (constructorName === "") {
|
|
227
|
-
const newConstructorName = new errorLike().name;
|
|
228
|
-
constructorName = newConstructorName || constructorName;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return constructorName;
|
|
232
|
-
}
|
|
233
|
-
__name(getConstructorName, "getConstructorName");
|
|
234
|
-
function getMessage(errorLike) {
|
|
235
|
-
let msg = "";
|
|
236
|
-
if (errorLike && errorLike.message) {
|
|
237
|
-
msg = errorLike.message;
|
|
238
|
-
} else if (typeof errorLike === "string") {
|
|
239
|
-
msg = errorLike;
|
|
240
|
-
}
|
|
241
|
-
return msg;
|
|
242
|
-
}
|
|
243
|
-
__name(getMessage, "getMessage");
|
|
244
|
-
function flag(obj, key, value) {
|
|
245
|
-
let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
246
|
-
if (arguments.length === 3) {
|
|
247
|
-
flags[key] = value;
|
|
248
|
-
} else {
|
|
249
|
-
return flags[key];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
__name(flag, "flag");
|
|
253
|
-
function test(obj, args) {
|
|
254
|
-
let negate = flag(obj, "negate"), expr = args[0];
|
|
255
|
-
return negate ? !expr : expr;
|
|
256
|
-
}
|
|
257
|
-
__name(test, "test");
|
|
258
|
-
function type(obj) {
|
|
259
|
-
if (typeof obj === "undefined") {
|
|
260
|
-
return "undefined";
|
|
261
|
-
}
|
|
262
|
-
if (obj === null) {
|
|
263
|
-
return "null";
|
|
264
|
-
}
|
|
265
|
-
const stringTag = obj[Symbol.toStringTag];
|
|
266
|
-
if (typeof stringTag === "string") {
|
|
267
|
-
return stringTag;
|
|
268
|
-
}
|
|
269
|
-
const type3 = Object.prototype.toString.call(obj).slice(8, -1);
|
|
270
|
-
return type3;
|
|
271
|
-
}
|
|
272
|
-
__name(type, "type");
|
|
273
|
-
var canElideFrames = "captureStackTrace" in Error;
|
|
274
|
-
var _AssertionError = class _AssertionError2 extends Error {
|
|
275
|
-
constructor(message = "Unspecified AssertionError", props, ssf) {
|
|
276
|
-
super(message);
|
|
277
|
-
__publicField(this, "message");
|
|
278
|
-
this.message = message;
|
|
279
|
-
if (canElideFrames) {
|
|
280
|
-
Error.captureStackTrace(this, ssf || _AssertionError2);
|
|
281
|
-
}
|
|
282
|
-
for (const key in props) {
|
|
283
|
-
if (!(key in this)) {
|
|
284
|
-
this[key] = props[key];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
get name() {
|
|
289
|
-
return "AssertionError";
|
|
290
|
-
}
|
|
291
|
-
get ok() {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
toJSON(stack) {
|
|
295
|
-
return {
|
|
296
|
-
...this,
|
|
297
|
-
name: this.name,
|
|
298
|
-
message: this.message,
|
|
299
|
-
ok: false,
|
|
300
|
-
stack: stack !== false ? this.stack : undefined
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
__name(_AssertionError, "AssertionError");
|
|
305
|
-
var AssertionError = _AssertionError;
|
|
306
|
-
function expectTypes(obj, types) {
|
|
307
|
-
let flagMsg = flag(obj, "message");
|
|
308
|
-
let ssfi = flag(obj, "ssfi");
|
|
309
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
310
|
-
obj = flag(obj, "object");
|
|
311
|
-
types = types.map(function(t) {
|
|
312
|
-
return t.toLowerCase();
|
|
313
|
-
});
|
|
314
|
-
types.sort();
|
|
315
|
-
let str = types.map(function(t, index) {
|
|
316
|
-
let art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a";
|
|
317
|
-
let or = types.length > 1 && index === types.length - 1 ? "or " : "";
|
|
318
|
-
return or + art + " " + t;
|
|
319
|
-
}).join(", ");
|
|
320
|
-
let objType = type(obj).toLowerCase();
|
|
321
|
-
if (!types.some(function(expected) {
|
|
322
|
-
return objType === expected;
|
|
323
|
-
})) {
|
|
324
|
-
throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", undefined, ssfi);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
__name(expectTypes, "expectTypes");
|
|
328
|
-
function getActual(obj, args) {
|
|
329
|
-
return args.length > 4 ? args[4] : obj._obj;
|
|
330
|
-
}
|
|
331
|
-
__name(getActual, "getActual");
|
|
332
|
-
var ansiColors = {
|
|
333
|
-
bold: ["1", "22"],
|
|
334
|
-
dim: ["2", "22"],
|
|
335
|
-
italic: ["3", "23"],
|
|
336
|
-
underline: ["4", "24"],
|
|
337
|
-
inverse: ["7", "27"],
|
|
338
|
-
hidden: ["8", "28"],
|
|
339
|
-
strike: ["9", "29"],
|
|
340
|
-
black: ["30", "39"],
|
|
341
|
-
red: ["31", "39"],
|
|
342
|
-
green: ["32", "39"],
|
|
343
|
-
yellow: ["33", "39"],
|
|
344
|
-
blue: ["34", "39"],
|
|
345
|
-
magenta: ["35", "39"],
|
|
346
|
-
cyan: ["36", "39"],
|
|
347
|
-
white: ["37", "39"],
|
|
348
|
-
brightblack: ["30;1", "39"],
|
|
349
|
-
brightred: ["31;1", "39"],
|
|
350
|
-
brightgreen: ["32;1", "39"],
|
|
351
|
-
brightyellow: ["33;1", "39"],
|
|
352
|
-
brightblue: ["34;1", "39"],
|
|
353
|
-
brightmagenta: ["35;1", "39"],
|
|
354
|
-
brightcyan: ["36;1", "39"],
|
|
355
|
-
brightwhite: ["37;1", "39"],
|
|
356
|
-
grey: ["90", "39"]
|
|
357
|
-
};
|
|
358
|
-
var styles = {
|
|
359
|
-
special: "cyan",
|
|
360
|
-
number: "yellow",
|
|
361
|
-
bigint: "yellow",
|
|
362
|
-
boolean: "yellow",
|
|
363
|
-
undefined: "grey",
|
|
364
|
-
null: "bold",
|
|
365
|
-
string: "green",
|
|
366
|
-
symbol: "green",
|
|
367
|
-
date: "magenta",
|
|
368
|
-
regexp: "red"
|
|
369
|
-
};
|
|
370
|
-
var truncator = "…";
|
|
371
|
-
function colorise(value, styleType) {
|
|
372
|
-
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
|
373
|
-
if (!color) {
|
|
374
|
-
return String(value);
|
|
375
|
-
}
|
|
376
|
-
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
|
377
|
-
}
|
|
378
|
-
__name(colorise, "colorise");
|
|
379
|
-
function normaliseOptions({
|
|
380
|
-
showHidden = false,
|
|
381
|
-
depth = 2,
|
|
382
|
-
colors = false,
|
|
383
|
-
customInspect = true,
|
|
384
|
-
showProxy = false,
|
|
385
|
-
maxArrayLength = Infinity,
|
|
386
|
-
breakLength = Infinity,
|
|
387
|
-
seen = [],
|
|
388
|
-
truncate: truncate2 = Infinity,
|
|
389
|
-
stylize = String
|
|
390
|
-
} = {}, inspect3) {
|
|
391
|
-
const options = {
|
|
392
|
-
showHidden: Boolean(showHidden),
|
|
393
|
-
depth: Number(depth),
|
|
394
|
-
colors: Boolean(colors),
|
|
395
|
-
customInspect: Boolean(customInspect),
|
|
396
|
-
showProxy: Boolean(showProxy),
|
|
397
|
-
maxArrayLength: Number(maxArrayLength),
|
|
398
|
-
breakLength: Number(breakLength),
|
|
399
|
-
truncate: Number(truncate2),
|
|
400
|
-
seen,
|
|
401
|
-
inspect: inspect3,
|
|
402
|
-
stylize
|
|
403
|
-
};
|
|
404
|
-
if (options.colors) {
|
|
405
|
-
options.stylize = colorise;
|
|
406
|
-
}
|
|
407
|
-
return options;
|
|
408
|
-
}
|
|
409
|
-
__name(normaliseOptions, "normaliseOptions");
|
|
410
|
-
function isHighSurrogate(char) {
|
|
411
|
-
return char >= "\uD800" && char <= "\uDBFF";
|
|
412
|
-
}
|
|
413
|
-
__name(isHighSurrogate, "isHighSurrogate");
|
|
414
|
-
function truncate(string, length, tail = truncator) {
|
|
415
|
-
string = String(string);
|
|
416
|
-
const tailLength = tail.length;
|
|
417
|
-
const stringLength = string.length;
|
|
418
|
-
if (tailLength > length && stringLength > tailLength) {
|
|
419
|
-
return tail;
|
|
420
|
-
}
|
|
421
|
-
if (stringLength > length && stringLength > tailLength) {
|
|
422
|
-
let end = length - tailLength;
|
|
423
|
-
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
|
424
|
-
end = end - 1;
|
|
425
|
-
}
|
|
426
|
-
return `${string.slice(0, end)}${tail}`;
|
|
427
|
-
}
|
|
428
|
-
return string;
|
|
429
|
-
}
|
|
430
|
-
__name(truncate, "truncate");
|
|
431
|
-
function inspectList(list, options, inspectItem, separator = ", ") {
|
|
432
|
-
inspectItem = inspectItem || options.inspect;
|
|
433
|
-
const size = list.length;
|
|
434
|
-
if (size === 0)
|
|
435
|
-
return "";
|
|
436
|
-
const originalLength = options.truncate;
|
|
437
|
-
let output = "";
|
|
438
|
-
let peek = "";
|
|
439
|
-
let truncated = "";
|
|
440
|
-
for (let i = 0;i < size; i += 1) {
|
|
441
|
-
const last = i + 1 === list.length;
|
|
442
|
-
const secondToLast = i + 2 === list.length;
|
|
443
|
-
truncated = `${truncator}(${list.length - i})`;
|
|
444
|
-
const value = list[i];
|
|
445
|
-
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
446
|
-
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
447
|
-
const nextLength = output.length + string.length;
|
|
448
|
-
const truncatedLength = nextLength + truncated.length;
|
|
449
|
-
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
453
|
-
break;
|
|
454
|
-
}
|
|
455
|
-
peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
|
|
456
|
-
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
output += string;
|
|
460
|
-
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
461
|
-
truncated = `${truncator}(${list.length - i - 1})`;
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
truncated = "";
|
|
465
|
-
}
|
|
466
|
-
return `${output}${truncated}`;
|
|
467
|
-
}
|
|
468
|
-
__name(inspectList, "inspectList");
|
|
469
|
-
function quoteComplexKey(key) {
|
|
470
|
-
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
471
|
-
return key;
|
|
472
|
-
}
|
|
473
|
-
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
474
|
-
}
|
|
475
|
-
__name(quoteComplexKey, "quoteComplexKey");
|
|
476
|
-
function inspectProperty([key, value], options) {
|
|
477
|
-
options.truncate -= 2;
|
|
478
|
-
if (typeof key === "string") {
|
|
479
|
-
key = quoteComplexKey(key);
|
|
480
|
-
} else if (typeof key !== "number") {
|
|
481
|
-
key = `[${options.inspect(key, options)}]`;
|
|
482
|
-
}
|
|
483
|
-
options.truncate -= key.length;
|
|
484
|
-
value = options.inspect(value, options);
|
|
485
|
-
return `${key}: ${value}`;
|
|
486
|
-
}
|
|
487
|
-
__name(inspectProperty, "inspectProperty");
|
|
488
|
-
function inspectArray(array, options) {
|
|
489
|
-
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
490
|
-
if (!array.length && !nonIndexProperties.length)
|
|
491
|
-
return "[]";
|
|
492
|
-
options.truncate -= 4;
|
|
493
|
-
const listContents = inspectList(array, options);
|
|
494
|
-
options.truncate -= listContents.length;
|
|
495
|
-
let propertyContents = "";
|
|
496
|
-
if (nonIndexProperties.length) {
|
|
497
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
498
|
-
}
|
|
499
|
-
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
500
|
-
}
|
|
501
|
-
__name(inspectArray, "inspectArray");
|
|
502
|
-
var getArrayName = /* @__PURE__ */ __name((array) => {
|
|
503
|
-
if (typeof Buffer === "function" && array instanceof Buffer) {
|
|
504
|
-
return "Buffer";
|
|
505
|
-
}
|
|
506
|
-
if (array[Symbol.toStringTag]) {
|
|
507
|
-
return array[Symbol.toStringTag];
|
|
508
|
-
}
|
|
509
|
-
return array.constructor.name;
|
|
510
|
-
}, "getArrayName");
|
|
511
|
-
function inspectTypedArray(array, options) {
|
|
512
|
-
const name = getArrayName(array);
|
|
513
|
-
options.truncate -= name.length + 4;
|
|
514
|
-
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
515
|
-
if (!array.length && !nonIndexProperties.length)
|
|
516
|
-
return `${name}[]`;
|
|
517
|
-
let output = "";
|
|
518
|
-
for (let i = 0;i < array.length; i++) {
|
|
519
|
-
const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
|
|
520
|
-
options.truncate -= string.length;
|
|
521
|
-
if (array[i] !== array.length && options.truncate <= 3) {
|
|
522
|
-
output += `${truncator}(${array.length - array[i] + 1})`;
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
output += string;
|
|
526
|
-
}
|
|
527
|
-
let propertyContents = "";
|
|
528
|
-
if (nonIndexProperties.length) {
|
|
529
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
530
|
-
}
|
|
531
|
-
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
532
|
-
}
|
|
533
|
-
__name(inspectTypedArray, "inspectTypedArray");
|
|
534
|
-
function inspectDate(dateObject, options) {
|
|
535
|
-
const stringRepresentation = dateObject.toJSON();
|
|
536
|
-
if (stringRepresentation === null) {
|
|
537
|
-
return "Invalid Date";
|
|
538
|
-
}
|
|
539
|
-
const split = stringRepresentation.split("T");
|
|
540
|
-
const date = split[0];
|
|
541
|
-
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
|
542
|
-
}
|
|
543
|
-
__name(inspectDate, "inspectDate");
|
|
544
|
-
function inspectFunction(func, options) {
|
|
545
|
-
const functionType = func[Symbol.toStringTag] || "Function";
|
|
546
|
-
const name = func.name;
|
|
547
|
-
if (!name) {
|
|
548
|
-
return options.stylize(`[${functionType}]`, "special");
|
|
549
|
-
}
|
|
550
|
-
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
|
551
|
-
}
|
|
552
|
-
__name(inspectFunction, "inspectFunction");
|
|
553
|
-
function inspectMapEntry([key, value], options) {
|
|
554
|
-
options.truncate -= 4;
|
|
555
|
-
key = options.inspect(key, options);
|
|
556
|
-
options.truncate -= key.length;
|
|
557
|
-
value = options.inspect(value, options);
|
|
558
|
-
return `${key} => ${value}`;
|
|
559
|
-
}
|
|
560
|
-
__name(inspectMapEntry, "inspectMapEntry");
|
|
561
|
-
function mapToEntries(map) {
|
|
562
|
-
const entries = [];
|
|
563
|
-
map.forEach((value, key) => {
|
|
564
|
-
entries.push([key, value]);
|
|
565
|
-
});
|
|
566
|
-
return entries;
|
|
567
|
-
}
|
|
568
|
-
__name(mapToEntries, "mapToEntries");
|
|
569
|
-
function inspectMap(map, options) {
|
|
570
|
-
if (map.size === 0)
|
|
571
|
-
return "Map{}";
|
|
572
|
-
options.truncate -= 7;
|
|
573
|
-
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
574
|
-
}
|
|
575
|
-
__name(inspectMap, "inspectMap");
|
|
576
|
-
var isNaN = Number.isNaN || ((i) => i !== i);
|
|
577
|
-
function inspectNumber(number, options) {
|
|
578
|
-
if (isNaN(number)) {
|
|
579
|
-
return options.stylize("NaN", "number");
|
|
580
|
-
}
|
|
581
|
-
if (number === Infinity) {
|
|
582
|
-
return options.stylize("Infinity", "number");
|
|
583
|
-
}
|
|
584
|
-
if (number === -Infinity) {
|
|
585
|
-
return options.stylize("-Infinity", "number");
|
|
586
|
-
}
|
|
587
|
-
if (number === 0) {
|
|
588
|
-
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
589
|
-
}
|
|
590
|
-
return options.stylize(truncate(String(number), options.truncate), "number");
|
|
591
|
-
}
|
|
592
|
-
__name(inspectNumber, "inspectNumber");
|
|
593
|
-
function inspectBigInt(number, options) {
|
|
594
|
-
let nums = truncate(number.toString(), options.truncate - 1);
|
|
595
|
-
if (nums !== truncator)
|
|
596
|
-
nums += "n";
|
|
597
|
-
return options.stylize(nums, "bigint");
|
|
598
|
-
}
|
|
599
|
-
__name(inspectBigInt, "inspectBigInt");
|
|
600
|
-
function inspectRegExp(value, options) {
|
|
601
|
-
const flags = value.toString().split("/")[2];
|
|
602
|
-
const sourceLength = options.truncate - (2 + flags.length);
|
|
603
|
-
const source = value.source;
|
|
604
|
-
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
|
|
605
|
-
}
|
|
606
|
-
__name(inspectRegExp, "inspectRegExp");
|
|
607
|
-
function arrayFromSet(set2) {
|
|
608
|
-
const values = [];
|
|
609
|
-
set2.forEach((value) => {
|
|
610
|
-
values.push(value);
|
|
611
|
-
});
|
|
612
|
-
return values;
|
|
613
|
-
}
|
|
614
|
-
__name(arrayFromSet, "arrayFromSet");
|
|
615
|
-
function inspectSet(set2, options) {
|
|
616
|
-
if (set2.size === 0)
|
|
617
|
-
return "Set{}";
|
|
618
|
-
options.truncate -= 7;
|
|
619
|
-
return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
|
|
620
|
-
}
|
|
621
|
-
__name(inspectSet, "inspectSet");
|
|
622
|
-
var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
623
|
-
var escapeCharacters = {
|
|
624
|
-
"\b": "\\b",
|
|
625
|
-
"\t": "\\t",
|
|
626
|
-
"\n": "\\n",
|
|
627
|
-
"\f": "\\f",
|
|
628
|
-
"\r": "\\r",
|
|
629
|
-
"'": "\\'",
|
|
630
|
-
"\\": "\\\\"
|
|
631
|
-
};
|
|
632
|
-
var hex = 16;
|
|
633
|
-
var unicodeLength = 4;
|
|
634
|
-
function escape(char) {
|
|
635
|
-
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
|
|
636
|
-
}
|
|
637
|
-
__name(escape, "escape");
|
|
638
|
-
function inspectString(string, options) {
|
|
639
|
-
if (stringEscapeChars.test(string)) {
|
|
640
|
-
string = string.replace(stringEscapeChars, escape);
|
|
641
|
-
}
|
|
642
|
-
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
|
643
|
-
}
|
|
644
|
-
__name(inspectString, "inspectString");
|
|
645
|
-
function inspectSymbol(value) {
|
|
646
|
-
if ("description" in Symbol.prototype) {
|
|
647
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
648
|
-
}
|
|
649
|
-
return value.toString();
|
|
650
|
-
}
|
|
651
|
-
__name(inspectSymbol, "inspectSymbol");
|
|
652
|
-
var getPromiseValue = /* @__PURE__ */ __name(() => "Promise{…}", "getPromiseValue");
|
|
653
|
-
var promise_default = getPromiseValue;
|
|
654
|
-
function inspectObject(object, options) {
|
|
655
|
-
const properties = Object.getOwnPropertyNames(object);
|
|
656
|
-
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
657
|
-
if (properties.length === 0 && symbols.length === 0) {
|
|
658
|
-
return "{}";
|
|
659
|
-
}
|
|
660
|
-
options.truncate -= 4;
|
|
661
|
-
options.seen = options.seen || [];
|
|
662
|
-
if (options.seen.includes(object)) {
|
|
663
|
-
return "[Circular]";
|
|
664
|
-
}
|
|
665
|
-
options.seen.push(object);
|
|
666
|
-
const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
|
|
667
|
-
const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
|
|
668
|
-
options.seen.pop();
|
|
669
|
-
let sep = "";
|
|
670
|
-
if (propertyContents && symbolContents) {
|
|
671
|
-
sep = ", ";
|
|
672
|
-
}
|
|
673
|
-
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
674
|
-
}
|
|
675
|
-
__name(inspectObject, "inspectObject");
|
|
676
|
-
var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
677
|
-
function inspectClass(value, options) {
|
|
678
|
-
let name = "";
|
|
679
|
-
if (toStringTag && toStringTag in value) {
|
|
680
|
-
name = value[toStringTag];
|
|
681
|
-
}
|
|
682
|
-
name = name || value.constructor.name;
|
|
683
|
-
if (!name || name === "_class") {
|
|
684
|
-
name = "<Anonymous Class>";
|
|
685
|
-
}
|
|
686
|
-
options.truncate -= name.length;
|
|
687
|
-
return `${name}${inspectObject(value, options)}`;
|
|
688
|
-
}
|
|
689
|
-
__name(inspectClass, "inspectClass");
|
|
690
|
-
function inspectArguments(args, options) {
|
|
691
|
-
if (args.length === 0)
|
|
692
|
-
return "Arguments[]";
|
|
693
|
-
options.truncate -= 13;
|
|
694
|
-
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
695
|
-
}
|
|
696
|
-
__name(inspectArguments, "inspectArguments");
|
|
697
|
-
var errorKeys = [
|
|
698
|
-
"stack",
|
|
699
|
-
"line",
|
|
700
|
-
"column",
|
|
701
|
-
"name",
|
|
702
|
-
"message",
|
|
703
|
-
"fileName",
|
|
704
|
-
"lineNumber",
|
|
705
|
-
"columnNumber",
|
|
706
|
-
"number",
|
|
707
|
-
"description",
|
|
708
|
-
"cause"
|
|
709
|
-
];
|
|
710
|
-
function inspectObject2(error, options) {
|
|
711
|
-
const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
|
|
712
|
-
const name = error.name;
|
|
713
|
-
options.truncate -= name.length;
|
|
714
|
-
let message = "";
|
|
715
|
-
if (typeof error.message === "string") {
|
|
716
|
-
message = truncate(error.message, options.truncate);
|
|
717
|
-
} else {
|
|
718
|
-
properties.unshift("message");
|
|
719
|
-
}
|
|
720
|
-
message = message ? `: ${message}` : "";
|
|
721
|
-
options.truncate -= message.length + 5;
|
|
722
|
-
options.seen = options.seen || [];
|
|
723
|
-
if (options.seen.includes(error)) {
|
|
724
|
-
return "[Circular]";
|
|
725
|
-
}
|
|
726
|
-
options.seen.push(error);
|
|
727
|
-
const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
|
|
728
|
-
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
|
729
|
-
}
|
|
730
|
-
__name(inspectObject2, "inspectObject");
|
|
731
|
-
function inspectAttribute([key, value], options) {
|
|
732
|
-
options.truncate -= 3;
|
|
733
|
-
if (!value) {
|
|
734
|
-
return `${options.stylize(String(key), "yellow")}`;
|
|
735
|
-
}
|
|
736
|
-
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
737
|
-
}
|
|
738
|
-
__name(inspectAttribute, "inspectAttribute");
|
|
739
|
-
function inspectNodeCollection(collection, options) {
|
|
740
|
-
return inspectList(collection, options, inspectNode, `
|
|
741
|
-
`);
|
|
742
|
-
}
|
|
743
|
-
__name(inspectNodeCollection, "inspectNodeCollection");
|
|
744
|
-
function inspectNode(node, options) {
|
|
745
|
-
switch (node.nodeType) {
|
|
746
|
-
case 1:
|
|
747
|
-
return inspectHTML(node, options);
|
|
748
|
-
case 3:
|
|
749
|
-
return options.inspect(node.data, options);
|
|
750
|
-
default:
|
|
751
|
-
return options.inspect(node, options);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
__name(inspectNode, "inspectNode");
|
|
755
|
-
function inspectHTML(element, options) {
|
|
756
|
-
const properties = element.getAttributeNames();
|
|
757
|
-
const name = element.tagName.toLowerCase();
|
|
758
|
-
const head = options.stylize(`<${name}`, "special");
|
|
759
|
-
const headClose = options.stylize(`>`, "special");
|
|
760
|
-
const tail = options.stylize(`</${name}>`, "special");
|
|
761
|
-
options.truncate -= name.length * 2 + 5;
|
|
762
|
-
let propertyContents = "";
|
|
763
|
-
if (properties.length > 0) {
|
|
764
|
-
propertyContents += " ";
|
|
765
|
-
propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
|
|
766
|
-
}
|
|
767
|
-
options.truncate -= propertyContents.length;
|
|
768
|
-
const truncate2 = options.truncate;
|
|
769
|
-
let children = inspectNodeCollection(element.children, options);
|
|
770
|
-
if (children && children.length > truncate2) {
|
|
771
|
-
children = `${truncator}(${element.children.length})`;
|
|
772
|
-
}
|
|
773
|
-
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
774
|
-
}
|
|
775
|
-
__name(inspectHTML, "inspectHTML");
|
|
776
|
-
var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
777
|
-
var chaiInspect = symbolsSupported ? /* @__PURE__ */ Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
778
|
-
var nodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
779
|
-
var constructorMap = /* @__PURE__ */ new WeakMap;
|
|
780
|
-
var stringTagMap = {};
|
|
781
|
-
var baseTypesMap = {
|
|
782
|
-
undefined: /* @__PURE__ */ __name((value, options) => options.stylize("undefined", "undefined"), "undefined"),
|
|
783
|
-
null: /* @__PURE__ */ __name((value, options) => options.stylize("null", "null"), "null"),
|
|
784
|
-
boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "boolean"),
|
|
785
|
-
Boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "Boolean"),
|
|
786
|
-
number: inspectNumber,
|
|
787
|
-
Number: inspectNumber,
|
|
788
|
-
bigint: inspectBigInt,
|
|
789
|
-
BigInt: inspectBigInt,
|
|
790
|
-
string: inspectString,
|
|
791
|
-
String: inspectString,
|
|
792
|
-
function: inspectFunction,
|
|
793
|
-
Function: inspectFunction,
|
|
794
|
-
symbol: inspectSymbol,
|
|
795
|
-
Symbol: inspectSymbol,
|
|
796
|
-
Array: inspectArray,
|
|
797
|
-
Date: inspectDate,
|
|
798
|
-
Map: inspectMap,
|
|
799
|
-
Set: inspectSet,
|
|
800
|
-
RegExp: inspectRegExp,
|
|
801
|
-
Promise: promise_default,
|
|
802
|
-
WeakSet: /* @__PURE__ */ __name((value, options) => options.stylize("WeakSet{…}", "special"), "WeakSet"),
|
|
803
|
-
WeakMap: /* @__PURE__ */ __name((value, options) => options.stylize("WeakMap{…}", "special"), "WeakMap"),
|
|
804
|
-
Arguments: inspectArguments,
|
|
805
|
-
Int8Array: inspectTypedArray,
|
|
806
|
-
Uint8Array: inspectTypedArray,
|
|
807
|
-
Uint8ClampedArray: inspectTypedArray,
|
|
808
|
-
Int16Array: inspectTypedArray,
|
|
809
|
-
Uint16Array: inspectTypedArray,
|
|
810
|
-
Int32Array: inspectTypedArray,
|
|
811
|
-
Uint32Array: inspectTypedArray,
|
|
812
|
-
Float32Array: inspectTypedArray,
|
|
813
|
-
Float64Array: inspectTypedArray,
|
|
814
|
-
Generator: /* @__PURE__ */ __name(() => "", "Generator"),
|
|
815
|
-
DataView: /* @__PURE__ */ __name(() => "", "DataView"),
|
|
816
|
-
ArrayBuffer: /* @__PURE__ */ __name(() => "", "ArrayBuffer"),
|
|
817
|
-
Error: inspectObject2,
|
|
818
|
-
HTMLCollection: inspectNodeCollection,
|
|
819
|
-
NodeList: inspectNodeCollection
|
|
820
|
-
};
|
|
821
|
-
var inspectCustom = /* @__PURE__ */ __name((value, options, type3, inspectFn) => {
|
|
822
|
-
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
|
823
|
-
return value[chaiInspect](options);
|
|
824
|
-
}
|
|
825
|
-
if (nodeInspect in value && typeof value[nodeInspect] === "function") {
|
|
826
|
-
return value[nodeInspect](options.depth, options, inspectFn);
|
|
827
|
-
}
|
|
828
|
-
if ("inspect" in value && typeof value.inspect === "function") {
|
|
829
|
-
return value.inspect(options.depth, options);
|
|
830
|
-
}
|
|
831
|
-
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
|
832
|
-
return constructorMap.get(value.constructor)(value, options);
|
|
833
|
-
}
|
|
834
|
-
if (stringTagMap[type3]) {
|
|
835
|
-
return stringTagMap[type3](value, options);
|
|
836
|
-
}
|
|
837
|
-
return "";
|
|
838
|
-
}, "inspectCustom");
|
|
839
|
-
var toString = Object.prototype.toString;
|
|
840
|
-
function inspect(value, opts = {}) {
|
|
841
|
-
const options = normaliseOptions(opts, inspect);
|
|
842
|
-
const { customInspect } = options;
|
|
843
|
-
let type3 = value === null ? "null" : typeof value;
|
|
844
|
-
if (type3 === "object") {
|
|
845
|
-
type3 = toString.call(value).slice(8, -1);
|
|
846
|
-
}
|
|
847
|
-
if (type3 in baseTypesMap) {
|
|
848
|
-
return baseTypesMap[type3](value, options);
|
|
849
|
-
}
|
|
850
|
-
if (customInspect && value) {
|
|
851
|
-
const output = inspectCustom(value, options, type3, inspect);
|
|
852
|
-
if (output) {
|
|
853
|
-
if (typeof output === "string")
|
|
854
|
-
return output;
|
|
855
|
-
return inspect(output, options);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
859
|
-
if (proto === Object.prototype || proto === null) {
|
|
860
|
-
return inspectObject(value, options);
|
|
861
|
-
}
|
|
862
|
-
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
|
863
|
-
return inspectHTML(value, options);
|
|
864
|
-
}
|
|
865
|
-
if ("constructor" in value) {
|
|
866
|
-
if (value.constructor !== Object) {
|
|
867
|
-
return inspectClass(value, options);
|
|
868
|
-
}
|
|
869
|
-
return inspectObject(value, options);
|
|
870
|
-
}
|
|
871
|
-
if (value === Object(value)) {
|
|
872
|
-
return inspectObject(value, options);
|
|
873
|
-
}
|
|
874
|
-
return options.stylize(String(value), type3);
|
|
875
|
-
}
|
|
876
|
-
__name(inspect, "inspect");
|
|
877
|
-
var config = {
|
|
878
|
-
includeStack: false,
|
|
879
|
-
showDiff: true,
|
|
880
|
-
truncateThreshold: 40,
|
|
881
|
-
useProxy: true,
|
|
882
|
-
proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"],
|
|
883
|
-
deepEqual: null
|
|
884
|
-
};
|
|
885
|
-
function inspect2(obj, showHidden, depth, colors) {
|
|
886
|
-
let options = {
|
|
887
|
-
colors,
|
|
888
|
-
depth: typeof depth === "undefined" ? 2 : depth,
|
|
889
|
-
showHidden,
|
|
890
|
-
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
|
|
891
|
-
};
|
|
892
|
-
return inspect(obj, options);
|
|
893
|
-
}
|
|
894
|
-
__name(inspect2, "inspect");
|
|
895
|
-
function objDisplay(obj) {
|
|
896
|
-
let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
|
|
897
|
-
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
|
898
|
-
if (type3 === "[object Function]") {
|
|
899
|
-
return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
|
|
900
|
-
} else if (type3 === "[object Array]") {
|
|
901
|
-
return "[ Array(" + obj.length + ") ]";
|
|
902
|
-
} else if (type3 === "[object Object]") {
|
|
903
|
-
let keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
|
|
904
|
-
return "{ Object (" + kstr + ") }";
|
|
905
|
-
} else {
|
|
906
|
-
return str;
|
|
907
|
-
}
|
|
908
|
-
} else {
|
|
909
|
-
return str;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
__name(objDisplay, "objDisplay");
|
|
913
|
-
function getMessage2(obj, args) {
|
|
914
|
-
let negate = flag(obj, "negate");
|
|
915
|
-
let val = flag(obj, "object");
|
|
916
|
-
let expected = args[3];
|
|
917
|
-
let actual = getActual(obj, args);
|
|
918
|
-
let msg = negate ? args[2] : args[1];
|
|
919
|
-
let flagMsg = flag(obj, "message");
|
|
920
|
-
if (typeof msg === "function")
|
|
921
|
-
msg = msg();
|
|
922
|
-
msg = msg || "";
|
|
923
|
-
msg = msg.replace(/#\{this\}/g, function() {
|
|
924
|
-
return objDisplay(val);
|
|
925
|
-
}).replace(/#\{act\}/g, function() {
|
|
926
|
-
return objDisplay(actual);
|
|
927
|
-
}).replace(/#\{exp\}/g, function() {
|
|
928
|
-
return objDisplay(expected);
|
|
929
|
-
});
|
|
930
|
-
return flagMsg ? flagMsg + ": " + msg : msg;
|
|
931
|
-
}
|
|
932
|
-
__name(getMessage2, "getMessage");
|
|
933
|
-
function transferFlags(assertion, object, includeAll) {
|
|
934
|
-
let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
935
|
-
if (!object.__flags) {
|
|
936
|
-
object.__flags = /* @__PURE__ */ Object.create(null);
|
|
937
|
-
}
|
|
938
|
-
includeAll = arguments.length === 3 ? includeAll : true;
|
|
939
|
-
for (let flag3 in flags) {
|
|
940
|
-
if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
|
|
941
|
-
object.__flags[flag3] = flags[flag3];
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
__name(transferFlags, "transferFlags");
|
|
946
|
-
function type2(obj) {
|
|
947
|
-
if (typeof obj === "undefined") {
|
|
948
|
-
return "undefined";
|
|
949
|
-
}
|
|
950
|
-
if (obj === null) {
|
|
951
|
-
return "null";
|
|
952
|
-
}
|
|
953
|
-
const stringTag = obj[Symbol.toStringTag];
|
|
954
|
-
if (typeof stringTag === "string") {
|
|
955
|
-
return stringTag;
|
|
956
|
-
}
|
|
957
|
-
const sliceStart = 8;
|
|
958
|
-
const sliceEnd = -1;
|
|
959
|
-
return Object.prototype.toString.call(obj).slice(sliceStart, sliceEnd);
|
|
960
|
-
}
|
|
961
|
-
__name(type2, "type");
|
|
962
|
-
function FakeMap() {
|
|
963
|
-
this._key = "chai/deep-eql__" + Math.random() + Date.now();
|
|
964
|
-
}
|
|
965
|
-
__name(FakeMap, "FakeMap");
|
|
966
|
-
FakeMap.prototype = {
|
|
967
|
-
get: /* @__PURE__ */ __name(function get(key) {
|
|
968
|
-
return key[this._key];
|
|
969
|
-
}, "get"),
|
|
970
|
-
set: /* @__PURE__ */ __name(function set(key, value) {
|
|
971
|
-
if (Object.isExtensible(key)) {
|
|
972
|
-
Object.defineProperty(key, this._key, {
|
|
973
|
-
value,
|
|
974
|
-
configurable: true
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
}, "set")
|
|
978
|
-
};
|
|
979
|
-
var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
|
|
980
|
-
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
|
|
981
|
-
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
982
|
-
return null;
|
|
983
|
-
}
|
|
984
|
-
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
985
|
-
if (leftHandMap) {
|
|
986
|
-
var result = leftHandMap.get(rightHandOperand);
|
|
987
|
-
if (typeof result === "boolean") {
|
|
988
|
-
return result;
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
return null;
|
|
992
|
-
}
|
|
993
|
-
__name(memoizeCompare, "memoizeCompare");
|
|
994
|
-
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
|
995
|
-
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
996
|
-
return;
|
|
997
|
-
}
|
|
998
|
-
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
999
|
-
if (leftHandMap) {
|
|
1000
|
-
leftHandMap.set(rightHandOperand, result);
|
|
1001
|
-
} else {
|
|
1002
|
-
leftHandMap = new MemoizeMap;
|
|
1003
|
-
leftHandMap.set(rightHandOperand, result);
|
|
1004
|
-
memoizeMap.set(leftHandOperand, leftHandMap);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
__name(memoizeSet, "memoizeSet");
|
|
1008
|
-
var deep_eql_default = deepEqual;
|
|
1009
|
-
function deepEqual(leftHandOperand, rightHandOperand, options) {
|
|
1010
|
-
if (options && options.comparator) {
|
|
1011
|
-
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
1012
|
-
}
|
|
1013
|
-
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
1014
|
-
if (simpleResult !== null) {
|
|
1015
|
-
return simpleResult;
|
|
1016
|
-
}
|
|
1017
|
-
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
1018
|
-
}
|
|
1019
|
-
__name(deepEqual, "deepEqual");
|
|
1020
|
-
function simpleEqual(leftHandOperand, rightHandOperand) {
|
|
1021
|
-
if (leftHandOperand === rightHandOperand) {
|
|
1022
|
-
return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
|
|
1023
|
-
}
|
|
1024
|
-
if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) {
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
|
-
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
1028
|
-
return false;
|
|
1029
|
-
}
|
|
1030
|
-
return null;
|
|
1031
|
-
}
|
|
1032
|
-
__name(simpleEqual, "simpleEqual");
|
|
1033
|
-
function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
|
1034
|
-
options = options || {};
|
|
1035
|
-
options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap;
|
|
1036
|
-
var comparator = options && options.comparator;
|
|
1037
|
-
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
|
|
1038
|
-
if (memoizeResultLeft !== null) {
|
|
1039
|
-
return memoizeResultLeft;
|
|
1040
|
-
}
|
|
1041
|
-
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
|
|
1042
|
-
if (memoizeResultRight !== null) {
|
|
1043
|
-
return memoizeResultRight;
|
|
1044
|
-
}
|
|
1045
|
-
if (comparator) {
|
|
1046
|
-
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
|
|
1047
|
-
if (comparatorResult === false || comparatorResult === true) {
|
|
1048
|
-
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
|
|
1049
|
-
return comparatorResult;
|
|
1050
|
-
}
|
|
1051
|
-
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
1052
|
-
if (simpleResult !== null) {
|
|
1053
|
-
return simpleResult;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
var leftHandType = type2(leftHandOperand);
|
|
1057
|
-
if (leftHandType !== type2(rightHandOperand)) {
|
|
1058
|
-
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
|
|
1059
|
-
return false;
|
|
1060
|
-
}
|
|
1061
|
-
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
|
|
1062
|
-
var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
|
|
1063
|
-
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
|
|
1064
|
-
return result;
|
|
1065
|
-
}
|
|
1066
|
-
__name(extensiveDeepEqual, "extensiveDeepEqual");
|
|
1067
|
-
function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
|
|
1068
|
-
switch (leftHandType) {
|
|
1069
|
-
case "String":
|
|
1070
|
-
case "Number":
|
|
1071
|
-
case "Boolean":
|
|
1072
|
-
case "Date":
|
|
1073
|
-
return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
|
|
1074
|
-
case "Promise":
|
|
1075
|
-
case "Symbol":
|
|
1076
|
-
case "function":
|
|
1077
|
-
case "WeakMap":
|
|
1078
|
-
case "WeakSet":
|
|
1079
|
-
return leftHandOperand === rightHandOperand;
|
|
1080
|
-
case "Error":
|
|
1081
|
-
return keysEqual(leftHandOperand, rightHandOperand, ["name", "message", "code"], options);
|
|
1082
|
-
case "Arguments":
|
|
1083
|
-
case "Int8Array":
|
|
1084
|
-
case "Uint8Array":
|
|
1085
|
-
case "Uint8ClampedArray":
|
|
1086
|
-
case "Int16Array":
|
|
1087
|
-
case "Uint16Array":
|
|
1088
|
-
case "Int32Array":
|
|
1089
|
-
case "Uint32Array":
|
|
1090
|
-
case "Float32Array":
|
|
1091
|
-
case "Float64Array":
|
|
1092
|
-
case "Array":
|
|
1093
|
-
return iterableEqual(leftHandOperand, rightHandOperand, options);
|
|
1094
|
-
case "RegExp":
|
|
1095
|
-
return regexpEqual(leftHandOperand, rightHandOperand);
|
|
1096
|
-
case "Generator":
|
|
1097
|
-
return generatorEqual(leftHandOperand, rightHandOperand, options);
|
|
1098
|
-
case "DataView":
|
|
1099
|
-
return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
|
|
1100
|
-
case "ArrayBuffer":
|
|
1101
|
-
return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
|
|
1102
|
-
case "Set":
|
|
1103
|
-
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
1104
|
-
case "Map":
|
|
1105
|
-
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
1106
|
-
case "Temporal.PlainDate":
|
|
1107
|
-
case "Temporal.PlainTime":
|
|
1108
|
-
case "Temporal.PlainDateTime":
|
|
1109
|
-
case "Temporal.Instant":
|
|
1110
|
-
case "Temporal.ZonedDateTime":
|
|
1111
|
-
case "Temporal.PlainYearMonth":
|
|
1112
|
-
case "Temporal.PlainMonthDay":
|
|
1113
|
-
return leftHandOperand.equals(rightHandOperand);
|
|
1114
|
-
case "Temporal.Duration":
|
|
1115
|
-
return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
|
|
1116
|
-
case "Temporal.TimeZone":
|
|
1117
|
-
case "Temporal.Calendar":
|
|
1118
|
-
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
1119
|
-
default:
|
|
1120
|
-
return objectEqual(leftHandOperand, rightHandOperand, options);
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
__name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
|
|
1124
|
-
function regexpEqual(leftHandOperand, rightHandOperand) {
|
|
1125
|
-
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
1126
|
-
}
|
|
1127
|
-
__name(regexpEqual, "regexpEqual");
|
|
1128
|
-
function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
|
1129
|
-
try {
|
|
1130
|
-
if (leftHandOperand.size !== rightHandOperand.size) {
|
|
1131
|
-
return false;
|
|
1132
|
-
}
|
|
1133
|
-
if (leftHandOperand.size === 0) {
|
|
1134
|
-
return true;
|
|
1135
|
-
}
|
|
1136
|
-
} catch (sizeError) {
|
|
1137
|
-
return false;
|
|
1138
|
-
}
|
|
1139
|
-
var leftHandItems = [];
|
|
1140
|
-
var rightHandItems = [];
|
|
1141
|
-
leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
1142
|
-
leftHandItems.push([key, value]);
|
|
1143
|
-
}, "gatherEntries"));
|
|
1144
|
-
rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
1145
|
-
rightHandItems.push([key, value]);
|
|
1146
|
-
}, "gatherEntries"));
|
|
1147
|
-
return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
|
|
1148
|
-
}
|
|
1149
|
-
__name(entriesEqual, "entriesEqual");
|
|
1150
|
-
function iterableEqual(leftHandOperand, rightHandOperand, options) {
|
|
1151
|
-
var length = leftHandOperand.length;
|
|
1152
|
-
if (length !== rightHandOperand.length) {
|
|
1153
|
-
return false;
|
|
1154
|
-
}
|
|
1155
|
-
if (length === 0) {
|
|
1156
|
-
return true;
|
|
1157
|
-
}
|
|
1158
|
-
var index = -1;
|
|
1159
|
-
while (++index < length) {
|
|
1160
|
-
if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
|
|
1161
|
-
return false;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
return true;
|
|
1165
|
-
}
|
|
1166
|
-
__name(iterableEqual, "iterableEqual");
|
|
1167
|
-
function generatorEqual(leftHandOperand, rightHandOperand, options) {
|
|
1168
|
-
return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
|
|
1169
|
-
}
|
|
1170
|
-
__name(generatorEqual, "generatorEqual");
|
|
1171
|
-
function hasIteratorFunction(target) {
|
|
1172
|
-
return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function";
|
|
1173
|
-
}
|
|
1174
|
-
__name(hasIteratorFunction, "hasIteratorFunction");
|
|
1175
|
-
function getIteratorEntries(target) {
|
|
1176
|
-
if (hasIteratorFunction(target)) {
|
|
1177
|
-
try {
|
|
1178
|
-
return getGeneratorEntries(target[Symbol.iterator]());
|
|
1179
|
-
} catch (iteratorError) {
|
|
1180
|
-
return [];
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
return [];
|
|
1184
|
-
}
|
|
1185
|
-
__name(getIteratorEntries, "getIteratorEntries");
|
|
1186
|
-
function getGeneratorEntries(generator) {
|
|
1187
|
-
var generatorResult = generator.next();
|
|
1188
|
-
var accumulator = [generatorResult.value];
|
|
1189
|
-
while (generatorResult.done === false) {
|
|
1190
|
-
generatorResult = generator.next();
|
|
1191
|
-
accumulator.push(generatorResult.value);
|
|
1192
|
-
}
|
|
1193
|
-
return accumulator;
|
|
1194
|
-
}
|
|
1195
|
-
__name(getGeneratorEntries, "getGeneratorEntries");
|
|
1196
|
-
function getEnumerableKeys(target) {
|
|
1197
|
-
var keys = [];
|
|
1198
|
-
for (var key in target) {
|
|
1199
|
-
keys.push(key);
|
|
1200
|
-
}
|
|
1201
|
-
return keys;
|
|
1202
|
-
}
|
|
1203
|
-
__name(getEnumerableKeys, "getEnumerableKeys");
|
|
1204
|
-
function getEnumerableSymbols(target) {
|
|
1205
|
-
var keys = [];
|
|
1206
|
-
var allKeys = Object.getOwnPropertySymbols(target);
|
|
1207
|
-
for (var i = 0;i < allKeys.length; i += 1) {
|
|
1208
|
-
var key = allKeys[i];
|
|
1209
|
-
if (Object.getOwnPropertyDescriptor(target, key).enumerable) {
|
|
1210
|
-
keys.push(key);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
return keys;
|
|
1214
|
-
}
|
|
1215
|
-
__name(getEnumerableSymbols, "getEnumerableSymbols");
|
|
1216
|
-
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
|
1217
|
-
var length = keys.length;
|
|
1218
|
-
if (length === 0) {
|
|
1219
|
-
return true;
|
|
1220
|
-
}
|
|
1221
|
-
for (var i = 0;i < length; i += 1) {
|
|
1222
|
-
if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
|
|
1223
|
-
return false;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
return true;
|
|
1227
|
-
}
|
|
1228
|
-
__name(keysEqual, "keysEqual");
|
|
1229
|
-
function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
1230
|
-
var leftHandKeys = getEnumerableKeys(leftHandOperand);
|
|
1231
|
-
var rightHandKeys = getEnumerableKeys(rightHandOperand);
|
|
1232
|
-
var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
|
|
1233
|
-
var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
|
|
1234
|
-
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
|
1235
|
-
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
|
1236
|
-
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
|
|
1237
|
-
if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) {
|
|
1238
|
-
return false;
|
|
1239
|
-
}
|
|
1240
|
-
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
|
|
1241
|
-
}
|
|
1242
|
-
var leftHandEntries = getIteratorEntries(leftHandOperand);
|
|
1243
|
-
var rightHandEntries = getIteratorEntries(rightHandOperand);
|
|
1244
|
-
if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
|
|
1245
|
-
leftHandEntries.sort();
|
|
1246
|
-
rightHandEntries.sort();
|
|
1247
|
-
return iterableEqual(leftHandEntries, rightHandEntries, options);
|
|
1248
|
-
}
|
|
1249
|
-
if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) {
|
|
1250
|
-
return true;
|
|
1251
|
-
}
|
|
1252
|
-
return false;
|
|
1253
|
-
}
|
|
1254
|
-
__name(objectEqual, "objectEqual");
|
|
1255
|
-
function isPrimitive(value) {
|
|
1256
|
-
return value === null || typeof value !== "object";
|
|
1257
|
-
}
|
|
1258
|
-
__name(isPrimitive, "isPrimitive");
|
|
1259
|
-
function mapSymbols(arr) {
|
|
1260
|
-
return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
|
|
1261
|
-
if (typeof entry === "symbol") {
|
|
1262
|
-
return entry.toString();
|
|
1263
|
-
}
|
|
1264
|
-
return entry;
|
|
1265
|
-
}, "mapSymbol"));
|
|
1266
|
-
}
|
|
1267
|
-
__name(mapSymbols, "mapSymbols");
|
|
1268
|
-
function hasProperty(obj, name) {
|
|
1269
|
-
if (typeof obj === "undefined" || obj === null) {
|
|
1270
|
-
return false;
|
|
1271
|
-
}
|
|
1272
|
-
return name in Object(obj);
|
|
1273
|
-
}
|
|
1274
|
-
__name(hasProperty, "hasProperty");
|
|
1275
|
-
function parsePath(path) {
|
|
1276
|
-
const str = path.replace(/([^\\])\[/g, "$1.[");
|
|
1277
|
-
const parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
1278
|
-
return parts.map((value) => {
|
|
1279
|
-
if (value === "constructor" || value === "__proto__" || value === "prototype") {
|
|
1280
|
-
return {};
|
|
1281
|
-
}
|
|
1282
|
-
const regexp = /^\[(\d+)\]$/;
|
|
1283
|
-
const mArr = regexp.exec(value);
|
|
1284
|
-
let parsed = null;
|
|
1285
|
-
if (mArr) {
|
|
1286
|
-
parsed = { i: parseFloat(mArr[1]) };
|
|
1287
|
-
} else {
|
|
1288
|
-
parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1289
|
-
}
|
|
1290
|
-
return parsed;
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
__name(parsePath, "parsePath");
|
|
1294
|
-
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
1295
|
-
let temporaryValue = obj;
|
|
1296
|
-
let res = null;
|
|
1297
|
-
pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
|
|
1298
|
-
for (let i = 0;i < pathDepth; i++) {
|
|
1299
|
-
const part = parsed[i];
|
|
1300
|
-
if (temporaryValue) {
|
|
1301
|
-
if (typeof part.p === "undefined") {
|
|
1302
|
-
temporaryValue = temporaryValue[part.i];
|
|
1303
|
-
} else {
|
|
1304
|
-
temporaryValue = temporaryValue[part.p];
|
|
1305
|
-
}
|
|
1306
|
-
if (i === pathDepth - 1) {
|
|
1307
|
-
res = temporaryValue;
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
return res;
|
|
1312
|
-
}
|
|
1313
|
-
__name(internalGetPathValue, "internalGetPathValue");
|
|
1314
|
-
function getPathInfo(obj, path) {
|
|
1315
|
-
const parsed = parsePath(path);
|
|
1316
|
-
const last = parsed[parsed.length - 1];
|
|
1317
|
-
const info = {
|
|
1318
|
-
parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
|
|
1319
|
-
name: last.p || last.i,
|
|
1320
|
-
value: internalGetPathValue(obj, parsed)
|
|
1321
|
-
};
|
|
1322
|
-
info.exists = hasProperty(info.parent, info.name);
|
|
1323
|
-
return info;
|
|
1324
|
-
}
|
|
1325
|
-
__name(getPathInfo, "getPathInfo");
|
|
1326
|
-
var _Assertion = class _Assertion2 {
|
|
1327
|
-
constructor(obj, msg, ssfi, lockSsfi) {
|
|
1328
|
-
__publicField(this, "__flags", {});
|
|
1329
|
-
flag(this, "ssfi", ssfi || _Assertion2);
|
|
1330
|
-
flag(this, "lockSsfi", lockSsfi);
|
|
1331
|
-
flag(this, "object", obj);
|
|
1332
|
-
flag(this, "message", msg);
|
|
1333
|
-
flag(this, "eql", config.deepEqual || deep_eql_default);
|
|
1334
|
-
return proxify(this);
|
|
1335
|
-
}
|
|
1336
|
-
static get includeStack() {
|
|
1337
|
-
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
1338
|
-
return config.includeStack;
|
|
1339
|
-
}
|
|
1340
|
-
static set includeStack(value) {
|
|
1341
|
-
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
1342
|
-
config.includeStack = value;
|
|
1343
|
-
}
|
|
1344
|
-
static get showDiff() {
|
|
1345
|
-
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
1346
|
-
return config.showDiff;
|
|
1347
|
-
}
|
|
1348
|
-
static set showDiff(value) {
|
|
1349
|
-
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
1350
|
-
config.showDiff = value;
|
|
1351
|
-
}
|
|
1352
|
-
static addProperty(name, fn) {
|
|
1353
|
-
addProperty(this.prototype, name, fn);
|
|
1354
|
-
}
|
|
1355
|
-
static addMethod(name, fn) {
|
|
1356
|
-
addMethod(this.prototype, name, fn);
|
|
1357
|
-
}
|
|
1358
|
-
static addChainableMethod(name, fn, chainingBehavior) {
|
|
1359
|
-
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1360
|
-
}
|
|
1361
|
-
static overwriteProperty(name, fn) {
|
|
1362
|
-
overwriteProperty(this.prototype, name, fn);
|
|
1363
|
-
}
|
|
1364
|
-
static overwriteMethod(name, fn) {
|
|
1365
|
-
overwriteMethod(this.prototype, name, fn);
|
|
1366
|
-
}
|
|
1367
|
-
static overwriteChainableMethod(name, fn, chainingBehavior) {
|
|
1368
|
-
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1369
|
-
}
|
|
1370
|
-
assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
|
|
1371
|
-
const ok = test(this, arguments);
|
|
1372
|
-
if (showDiff !== false)
|
|
1373
|
-
showDiff = true;
|
|
1374
|
-
if (expected === undefined && _actual === undefined)
|
|
1375
|
-
showDiff = false;
|
|
1376
|
-
if (config.showDiff !== true)
|
|
1377
|
-
showDiff = false;
|
|
1378
|
-
if (!ok) {
|
|
1379
|
-
msg = getMessage2(this, arguments);
|
|
1380
|
-
const actual = getActual(this, arguments);
|
|
1381
|
-
const assertionErrorObjectProperties = {
|
|
1382
|
-
actual,
|
|
1383
|
-
expected,
|
|
1384
|
-
showDiff
|
|
1385
|
-
};
|
|
1386
|
-
const operator = getOperator(this, arguments);
|
|
1387
|
-
if (operator) {
|
|
1388
|
-
assertionErrorObjectProperties.operator = operator;
|
|
1389
|
-
}
|
|
1390
|
-
throw new AssertionError(msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi"));
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
get _obj() {
|
|
1394
|
-
return flag(this, "object");
|
|
1395
|
-
}
|
|
1396
|
-
set _obj(val) {
|
|
1397
|
-
flag(this, "object", val);
|
|
1398
|
-
}
|
|
1399
|
-
};
|
|
1400
|
-
__name(_Assertion, "Assertion");
|
|
1401
|
-
var Assertion = _Assertion;
|
|
1402
|
-
var events = new EventTarget;
|
|
1403
|
-
var _PluginEvent = class _PluginEvent2 extends Event {
|
|
1404
|
-
constructor(type3, name, fn) {
|
|
1405
|
-
super(type3);
|
|
1406
|
-
this.name = String(name);
|
|
1407
|
-
this.fn = fn;
|
|
1408
|
-
}
|
|
1409
|
-
};
|
|
1410
|
-
__name(_PluginEvent, "PluginEvent");
|
|
1411
|
-
var PluginEvent = _PluginEvent;
|
|
1412
|
-
function isProxyEnabled() {
|
|
1413
|
-
return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
|
|
1414
|
-
}
|
|
1415
|
-
__name(isProxyEnabled, "isProxyEnabled");
|
|
1416
|
-
function addProperty(ctx, name, getter) {
|
|
1417
|
-
getter = getter === undefined ? function() {} : getter;
|
|
1418
|
-
Object.defineProperty(ctx, name, {
|
|
1419
|
-
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
1420
|
-
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1421
|
-
flag(this, "ssfi", propertyGetter);
|
|
1422
|
-
}
|
|
1423
|
-
let result = getter.call(this);
|
|
1424
|
-
if (result !== undefined)
|
|
1425
|
-
return result;
|
|
1426
|
-
let newAssertion = new Assertion;
|
|
1427
|
-
transferFlags(this, newAssertion);
|
|
1428
|
-
return newAssertion;
|
|
1429
|
-
}, "propertyGetter"),
|
|
1430
|
-
configurable: true
|
|
1431
|
-
});
|
|
1432
|
-
events.dispatchEvent(new PluginEvent("addProperty", name, getter));
|
|
1433
|
-
}
|
|
1434
|
-
__name(addProperty, "addProperty");
|
|
1435
|
-
var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
|
|
1436
|
-
function addLengthGuard(fn, assertionName, isChainable) {
|
|
1437
|
-
if (!fnLengthDesc.configurable)
|
|
1438
|
-
return fn;
|
|
1439
|
-
Object.defineProperty(fn, "length", {
|
|
1440
|
-
get: /* @__PURE__ */ __name(function() {
|
|
1441
|
-
if (isChainable) {
|
|
1442
|
-
throw Error("Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.');
|
|
1443
|
-
}
|
|
1444
|
-
throw Error("Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".');
|
|
1445
|
-
}, "get")
|
|
1446
|
-
});
|
|
1447
|
-
return fn;
|
|
1448
|
-
}
|
|
1449
|
-
__name(addLengthGuard, "addLengthGuard");
|
|
1450
|
-
function getProperties(object) {
|
|
1451
|
-
let result = Object.getOwnPropertyNames(object);
|
|
1452
|
-
function addProperty2(property) {
|
|
1453
|
-
if (result.indexOf(property) === -1) {
|
|
1454
|
-
result.push(property);
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
__name(addProperty2, "addProperty");
|
|
1458
|
-
let proto = Object.getPrototypeOf(object);
|
|
1459
|
-
while (proto !== null) {
|
|
1460
|
-
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
1461
|
-
proto = Object.getPrototypeOf(proto);
|
|
1462
|
-
}
|
|
1463
|
-
return result;
|
|
1464
|
-
}
|
|
1465
|
-
__name(getProperties, "getProperties");
|
|
1466
|
-
var builtins = ["__flags", "__methods", "_obj", "assert"];
|
|
1467
|
-
function proxify(obj, nonChainableMethodName) {
|
|
1468
|
-
if (!isProxyEnabled())
|
|
1469
|
-
return obj;
|
|
1470
|
-
return new Proxy(obj, {
|
|
1471
|
-
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1472
|
-
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
1473
|
-
if (nonChainableMethodName) {
|
|
1474
|
-
throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".');
|
|
1475
|
-
}
|
|
1476
|
-
let suggestion = null;
|
|
1477
|
-
let suggestionDistance = 4;
|
|
1478
|
-
getProperties(target).forEach(function(prop) {
|
|
1479
|
-
if (!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1) {
|
|
1480
|
-
let dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
1481
|
-
if (dist < suggestionDistance) {
|
|
1482
|
-
suggestion = prop;
|
|
1483
|
-
suggestionDistance = dist;
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
});
|
|
1487
|
-
if (suggestion !== null) {
|
|
1488
|
-
throw Error("Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?');
|
|
1489
|
-
} else {
|
|
1490
|
-
throw Error("Invalid Chai property: " + property);
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) {
|
|
1494
|
-
flag(target, "ssfi", proxyGetter);
|
|
1495
|
-
}
|
|
1496
|
-
return Reflect.get(target, property);
|
|
1497
|
-
}, "proxyGetter")
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
__name(proxify, "proxify");
|
|
1501
|
-
function stringDistanceCapped(strA, strB, cap) {
|
|
1502
|
-
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
1503
|
-
return cap;
|
|
1504
|
-
}
|
|
1505
|
-
let memo = [];
|
|
1506
|
-
for (let i = 0;i <= strA.length; i++) {
|
|
1507
|
-
memo[i] = Array(strB.length + 1).fill(0);
|
|
1508
|
-
memo[i][0] = i;
|
|
1509
|
-
}
|
|
1510
|
-
for (let j = 0;j < strB.length; j++) {
|
|
1511
|
-
memo[0][j] = j;
|
|
1512
|
-
}
|
|
1513
|
-
for (let i = 1;i <= strA.length; i++) {
|
|
1514
|
-
let ch = strA.charCodeAt(i - 1);
|
|
1515
|
-
for (let j = 1;j <= strB.length; j++) {
|
|
1516
|
-
if (Math.abs(i - j) >= cap) {
|
|
1517
|
-
memo[i][j] = cap;
|
|
1518
|
-
continue;
|
|
1519
|
-
}
|
|
1520
|
-
memo[i][j] = Math.min(memo[i - 1][j] + 1, memo[i][j - 1] + 1, memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1));
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
return memo[strA.length][strB.length];
|
|
1524
|
-
}
|
|
1525
|
-
__name(stringDistanceCapped, "stringDistanceCapped");
|
|
1526
|
-
function addMethod(ctx, name, method) {
|
|
1527
|
-
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1528
|
-
if (!flag(this, "lockSsfi")) {
|
|
1529
|
-
flag(this, "ssfi", methodWrapper);
|
|
1530
|
-
}
|
|
1531
|
-
let result = method.apply(this, arguments);
|
|
1532
|
-
if (result !== undefined)
|
|
1533
|
-
return result;
|
|
1534
|
-
let newAssertion = new Assertion;
|
|
1535
|
-
transferFlags(this, newAssertion);
|
|
1536
|
-
return newAssertion;
|
|
1537
|
-
}, "methodWrapper");
|
|
1538
|
-
addLengthGuard(methodWrapper, name, false);
|
|
1539
|
-
ctx[name] = proxify(methodWrapper, name);
|
|
1540
|
-
events.dispatchEvent(new PluginEvent("addMethod", name, method));
|
|
1541
|
-
}
|
|
1542
|
-
__name(addMethod, "addMethod");
|
|
1543
|
-
function overwriteProperty(ctx, name, getter) {
|
|
1544
|
-
let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {}, "_super");
|
|
1545
|
-
if (_get && typeof _get.get === "function")
|
|
1546
|
-
_super = _get.get;
|
|
1547
|
-
Object.defineProperty(ctx, name, {
|
|
1548
|
-
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1549
|
-
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1550
|
-
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1551
|
-
}
|
|
1552
|
-
let origLockSsfi = flag(this, "lockSsfi");
|
|
1553
|
-
flag(this, "lockSsfi", true);
|
|
1554
|
-
let result = getter(_super).call(this);
|
|
1555
|
-
flag(this, "lockSsfi", origLockSsfi);
|
|
1556
|
-
if (result !== undefined) {
|
|
1557
|
-
return result;
|
|
1558
|
-
}
|
|
1559
|
-
let newAssertion = new Assertion;
|
|
1560
|
-
transferFlags(this, newAssertion);
|
|
1561
|
-
return newAssertion;
|
|
1562
|
-
}, "overwritingPropertyGetter"),
|
|
1563
|
-
configurable: true
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
1566
|
-
__name(overwriteProperty, "overwriteProperty");
|
|
1567
|
-
function overwriteMethod(ctx, name, method) {
|
|
1568
|
-
let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
1569
|
-
throw new Error(name + " is not a function");
|
|
1570
|
-
}, "_super");
|
|
1571
|
-
if (_method && typeof _method === "function")
|
|
1572
|
-
_super = _method;
|
|
1573
|
-
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1574
|
-
if (!flag(this, "lockSsfi")) {
|
|
1575
|
-
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1576
|
-
}
|
|
1577
|
-
let origLockSsfi = flag(this, "lockSsfi");
|
|
1578
|
-
flag(this, "lockSsfi", true);
|
|
1579
|
-
let result = method(_super).apply(this, arguments);
|
|
1580
|
-
flag(this, "lockSsfi", origLockSsfi);
|
|
1581
|
-
if (result !== undefined) {
|
|
1582
|
-
return result;
|
|
1583
|
-
}
|
|
1584
|
-
let newAssertion = new Assertion;
|
|
1585
|
-
transferFlags(this, newAssertion);
|
|
1586
|
-
return newAssertion;
|
|
1587
|
-
}, "overwritingMethodWrapper");
|
|
1588
|
-
addLengthGuard(overwritingMethodWrapper, name, false);
|
|
1589
|
-
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
1590
|
-
}
|
|
1591
|
-
__name(overwriteMethod, "overwriteMethod");
|
|
1592
|
-
var canSetPrototype = typeof Object.setPrototypeOf === "function";
|
|
1593
|
-
var testFn = /* @__PURE__ */ __name(function() {}, "testFn");
|
|
1594
|
-
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
1595
|
-
let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
1596
|
-
if (typeof propDesc !== "object")
|
|
1597
|
-
return true;
|
|
1598
|
-
return !propDesc.configurable;
|
|
1599
|
-
});
|
|
1600
|
-
var call = Function.prototype.call;
|
|
1601
|
-
var apply = Function.prototype.apply;
|
|
1602
|
-
var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent2 extends PluginEvent {
|
|
1603
|
-
constructor(type3, name, fn, chainingBehavior) {
|
|
1604
|
-
super(type3, name, fn);
|
|
1605
|
-
this.chainingBehavior = chainingBehavior;
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
__name(_PluginAddChainableMethodEvent, "PluginAddChainableMethodEvent");
|
|
1609
|
-
var PluginAddChainableMethodEvent = _PluginAddChainableMethodEvent;
|
|
1610
|
-
function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
1611
|
-
if (typeof chainingBehavior !== "function") {
|
|
1612
|
-
chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
|
|
1613
|
-
}
|
|
1614
|
-
let chainableBehavior = {
|
|
1615
|
-
method,
|
|
1616
|
-
chainingBehavior
|
|
1617
|
-
};
|
|
1618
|
-
if (!ctx.__methods) {
|
|
1619
|
-
ctx.__methods = {};
|
|
1620
|
-
}
|
|
1621
|
-
ctx.__methods[name] = chainableBehavior;
|
|
1622
|
-
Object.defineProperty(ctx, name, {
|
|
1623
|
-
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1624
|
-
chainableBehavior.chainingBehavior.call(this);
|
|
1625
|
-
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1626
|
-
if (!flag(this, "lockSsfi")) {
|
|
1627
|
-
flag(this, "ssfi", chainableMethodWrapper);
|
|
1628
|
-
}
|
|
1629
|
-
let result = chainableBehavior.method.apply(this, arguments);
|
|
1630
|
-
if (result !== undefined) {
|
|
1631
|
-
return result;
|
|
1632
|
-
}
|
|
1633
|
-
let newAssertion = new Assertion;
|
|
1634
|
-
transferFlags(this, newAssertion);
|
|
1635
|
-
return newAssertion;
|
|
1636
|
-
}, "chainableMethodWrapper");
|
|
1637
|
-
addLengthGuard(chainableMethodWrapper, name, true);
|
|
1638
|
-
if (canSetPrototype) {
|
|
1639
|
-
let prototype = Object.create(this);
|
|
1640
|
-
prototype.call = call;
|
|
1641
|
-
prototype.apply = apply;
|
|
1642
|
-
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1643
|
-
} else {
|
|
1644
|
-
let asserterNames = Object.getOwnPropertyNames(ctx);
|
|
1645
|
-
asserterNames.forEach(function(asserterName) {
|
|
1646
|
-
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1649
|
-
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1650
|
-
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1651
|
-
});
|
|
1652
|
-
}
|
|
1653
|
-
transferFlags(this, chainableMethodWrapper);
|
|
1654
|
-
return proxify(chainableMethodWrapper);
|
|
1655
|
-
}, "chainableMethodGetter"),
|
|
1656
|
-
configurable: true
|
|
1657
|
-
});
|
|
1658
|
-
events.dispatchEvent(new PluginAddChainableMethodEvent("addChainableMethod", name, method, chainingBehavior));
|
|
1659
|
-
}
|
|
1660
|
-
__name(addChainableMethod, "addChainableMethod");
|
|
1661
|
-
function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
1662
|
-
let chainableBehavior = ctx.__methods[name];
|
|
1663
|
-
let _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
1664
|
-
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
1665
|
-
let result = chainingBehavior(_chainingBehavior).call(this);
|
|
1666
|
-
if (result !== undefined) {
|
|
1667
|
-
return result;
|
|
1668
|
-
}
|
|
1669
|
-
let newAssertion = new Assertion;
|
|
1670
|
-
transferFlags(this, newAssertion);
|
|
1671
|
-
return newAssertion;
|
|
1672
|
-
}, "overwritingChainableMethodGetter");
|
|
1673
|
-
let _method = chainableBehavior.method;
|
|
1674
|
-
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
1675
|
-
let result = method(_method).apply(this, arguments);
|
|
1676
|
-
if (result !== undefined) {
|
|
1677
|
-
return result;
|
|
1678
|
-
}
|
|
1679
|
-
let newAssertion = new Assertion;
|
|
1680
|
-
transferFlags(this, newAssertion);
|
|
1681
|
-
return newAssertion;
|
|
1682
|
-
}, "overwritingChainableMethodWrapper");
|
|
1683
|
-
}
|
|
1684
|
-
__name(overwriteChainableMethod, "overwriteChainableMethod");
|
|
1685
|
-
function compareByInspect(a, b) {
|
|
1686
|
-
return inspect2(a) < inspect2(b) ? -1 : 1;
|
|
1687
|
-
}
|
|
1688
|
-
__name(compareByInspect, "compareByInspect");
|
|
1689
|
-
function getOwnEnumerablePropertySymbols(obj) {
|
|
1690
|
-
if (typeof Object.getOwnPropertySymbols !== "function")
|
|
1691
|
-
return [];
|
|
1692
|
-
return Object.getOwnPropertySymbols(obj).filter(function(sym) {
|
|
1693
|
-
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
|
-
__name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
|
|
1697
|
-
function getOwnEnumerableProperties(obj) {
|
|
1698
|
-
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
1699
|
-
}
|
|
1700
|
-
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
1701
|
-
var isNaN2 = Number.isNaN;
|
|
1702
|
-
function isObjectType(obj) {
|
|
1703
|
-
let objectType = type(obj);
|
|
1704
|
-
let objectTypes = ["Array", "Object", "Function"];
|
|
1705
|
-
return objectTypes.indexOf(objectType) !== -1;
|
|
1706
|
-
}
|
|
1707
|
-
__name(isObjectType, "isObjectType");
|
|
1708
|
-
function getOperator(obj, args) {
|
|
1709
|
-
let operator = flag(obj, "operator");
|
|
1710
|
-
let negate = flag(obj, "negate");
|
|
1711
|
-
let expected = args[3];
|
|
1712
|
-
let msg = negate ? args[2] : args[1];
|
|
1713
|
-
if (operator) {
|
|
1714
|
-
return operator;
|
|
1715
|
-
}
|
|
1716
|
-
if (typeof msg === "function")
|
|
1717
|
-
msg = msg();
|
|
1718
|
-
msg = msg || "";
|
|
1719
|
-
if (!msg) {
|
|
1720
|
-
return;
|
|
1721
|
-
}
|
|
1722
|
-
if (/\shave\s/.test(msg)) {
|
|
1723
|
-
return;
|
|
1724
|
-
}
|
|
1725
|
-
let isObject = isObjectType(expected);
|
|
1726
|
-
if (/\snot\s/.test(msg)) {
|
|
1727
|
-
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
1728
|
-
}
|
|
1729
|
-
return isObject ? "deepStrictEqual" : "strictEqual";
|
|
1730
|
-
}
|
|
1731
|
-
__name(getOperator, "getOperator");
|
|
1732
|
-
function getName(fn) {
|
|
1733
|
-
return fn.name;
|
|
1734
|
-
}
|
|
1735
|
-
__name(getName, "getName");
|
|
1736
|
-
function isRegExp2(obj) {
|
|
1737
|
-
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
1738
|
-
}
|
|
1739
|
-
__name(isRegExp2, "isRegExp");
|
|
1740
|
-
function isNumeric(obj) {
|
|
1741
|
-
return ["Number", "BigInt"].includes(type(obj));
|
|
1742
|
-
}
|
|
1743
|
-
__name(isNumeric, "isNumeric");
|
|
1744
|
-
var { flag: flag2 } = utils_exports;
|
|
1745
|
-
[
|
|
1746
|
-
"to",
|
|
1747
|
-
"be",
|
|
1748
|
-
"been",
|
|
1749
|
-
"is",
|
|
1750
|
-
"and",
|
|
1751
|
-
"has",
|
|
1752
|
-
"have",
|
|
1753
|
-
"with",
|
|
1754
|
-
"that",
|
|
1755
|
-
"which",
|
|
1756
|
-
"at",
|
|
1757
|
-
"of",
|
|
1758
|
-
"same",
|
|
1759
|
-
"but",
|
|
1760
|
-
"does",
|
|
1761
|
-
"still",
|
|
1762
|
-
"also"
|
|
1763
|
-
].forEach(function(chain) {
|
|
1764
|
-
Assertion.addProperty(chain);
|
|
1765
|
-
});
|
|
1766
|
-
Assertion.addProperty("not", function() {
|
|
1767
|
-
flag2(this, "negate", true);
|
|
1768
|
-
});
|
|
1769
|
-
Assertion.addProperty("deep", function() {
|
|
1770
|
-
flag2(this, "deep", true);
|
|
1771
|
-
});
|
|
1772
|
-
Assertion.addProperty("nested", function() {
|
|
1773
|
-
flag2(this, "nested", true);
|
|
1774
|
-
});
|
|
1775
|
-
Assertion.addProperty("own", function() {
|
|
1776
|
-
flag2(this, "own", true);
|
|
1777
|
-
});
|
|
1778
|
-
Assertion.addProperty("ordered", function() {
|
|
1779
|
-
flag2(this, "ordered", true);
|
|
1780
|
-
});
|
|
1781
|
-
Assertion.addProperty("any", function() {
|
|
1782
|
-
flag2(this, "any", true);
|
|
1783
|
-
flag2(this, "all", false);
|
|
1784
|
-
});
|
|
1785
|
-
Assertion.addProperty("all", function() {
|
|
1786
|
-
flag2(this, "all", true);
|
|
1787
|
-
flag2(this, "any", false);
|
|
1788
|
-
});
|
|
1789
|
-
var functionTypes = {
|
|
1790
|
-
function: [
|
|
1791
|
-
"function",
|
|
1792
|
-
"asyncfunction",
|
|
1793
|
-
"generatorfunction",
|
|
1794
|
-
"asyncgeneratorfunction"
|
|
1795
|
-
],
|
|
1796
|
-
asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
|
|
1797
|
-
generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
|
|
1798
|
-
asyncgeneratorfunction: ["asyncgeneratorfunction"]
|
|
1799
|
-
};
|
|
1800
|
-
function an(type3, msg) {
|
|
1801
|
-
if (msg)
|
|
1802
|
-
flag2(this, "message", msg);
|
|
1803
|
-
type3 = type3.toLowerCase();
|
|
1804
|
-
let obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
1805
|
-
const detectedType = type(obj).toLowerCase();
|
|
1806
|
-
if (functionTypes["function"].includes(type3)) {
|
|
1807
|
-
this.assert(functionTypes[type3].includes(detectedType), "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
1808
|
-
} else {
|
|
1809
|
-
this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
__name(an, "an");
|
|
1813
|
-
Assertion.addChainableMethod("an", an);
|
|
1814
|
-
Assertion.addChainableMethod("a", an);
|
|
1815
|
-
function SameValueZero(a, b) {
|
|
1816
|
-
return isNaN2(a) && isNaN2(b) || a === b;
|
|
1817
|
-
}
|
|
1818
|
-
__name(SameValueZero, "SameValueZero");
|
|
1819
|
-
function includeChainingBehavior() {
|
|
1820
|
-
flag2(this, "contains", true);
|
|
1821
|
-
}
|
|
1822
|
-
__name(includeChainingBehavior, "includeChainingBehavior");
|
|
1823
|
-
function include(val, msg) {
|
|
1824
|
-
if (msg)
|
|
1825
|
-
flag2(this, "message", msg);
|
|
1826
|
-
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
|
|
1827
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
1828
|
-
let included = false;
|
|
1829
|
-
switch (objType) {
|
|
1830
|
-
case "string":
|
|
1831
|
-
included = obj.indexOf(val) !== -1;
|
|
1832
|
-
break;
|
|
1833
|
-
case "weakset":
|
|
1834
|
-
if (isDeep) {
|
|
1835
|
-
throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", undefined, ssfi);
|
|
1836
|
-
}
|
|
1837
|
-
included = obj.has(val);
|
|
1838
|
-
break;
|
|
1839
|
-
case "map":
|
|
1840
|
-
obj.forEach(function(item) {
|
|
1841
|
-
included = included || isEql(item, val);
|
|
1842
|
-
});
|
|
1843
|
-
break;
|
|
1844
|
-
case "set":
|
|
1845
|
-
if (isDeep) {
|
|
1846
|
-
obj.forEach(function(item) {
|
|
1847
|
-
included = included || isEql(item, val);
|
|
1848
|
-
});
|
|
1849
|
-
} else {
|
|
1850
|
-
included = obj.has(val);
|
|
1851
|
-
}
|
|
1852
|
-
break;
|
|
1853
|
-
case "array":
|
|
1854
|
-
if (isDeep) {
|
|
1855
|
-
included = obj.some(function(item) {
|
|
1856
|
-
return isEql(item, val);
|
|
1857
|
-
});
|
|
1858
|
-
} else {
|
|
1859
|
-
included = obj.indexOf(val) !== -1;
|
|
1860
|
-
}
|
|
1861
|
-
break;
|
|
1862
|
-
default: {
|
|
1863
|
-
if (val !== Object(val)) {
|
|
1864
|
-
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(), undefined, ssfi);
|
|
1865
|
-
}
|
|
1866
|
-
let props = Object.keys(val);
|
|
1867
|
-
let firstErr = null;
|
|
1868
|
-
let numErrs = 0;
|
|
1869
|
-
props.forEach(function(prop) {
|
|
1870
|
-
let propAssertion = new Assertion(obj);
|
|
1871
|
-
transferFlags(this, propAssertion, true);
|
|
1872
|
-
flag2(propAssertion, "lockSsfi", true);
|
|
1873
|
-
if (!negate || props.length === 1) {
|
|
1874
|
-
propAssertion.property(prop, val[prop]);
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
try {
|
|
1878
|
-
propAssertion.property(prop, val[prop]);
|
|
1879
|
-
} catch (err) {
|
|
1880
|
-
if (!check_error_exports.compatibleConstructor(err, AssertionError)) {
|
|
1881
|
-
throw err;
|
|
1882
|
-
}
|
|
1883
|
-
if (firstErr === null)
|
|
1884
|
-
firstErr = err;
|
|
1885
|
-
numErrs++;
|
|
1886
|
-
}
|
|
1887
|
-
}, this);
|
|
1888
|
-
if (negate && props.length > 1 && numErrs === props.length) {
|
|
1889
|
-
throw firstErr;
|
|
1890
|
-
}
|
|
1891
|
-
return;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
this.assert(included, "expected #{this} to " + descriptor + "include " + inspect2(val), "expected #{this} to not " + descriptor + "include " + inspect2(val));
|
|
1895
|
-
}
|
|
1896
|
-
__name(include, "include");
|
|
1897
|
-
Assertion.addChainableMethod("include", include, includeChainingBehavior);
|
|
1898
|
-
Assertion.addChainableMethod("contain", include, includeChainingBehavior);
|
|
1899
|
-
Assertion.addChainableMethod("contains", include, includeChainingBehavior);
|
|
1900
|
-
Assertion.addChainableMethod("includes", include, includeChainingBehavior);
|
|
1901
|
-
Assertion.addProperty("ok", function() {
|
|
1902
|
-
this.assert(flag2(this, "object"), "expected #{this} to be truthy", "expected #{this} to be falsy");
|
|
1903
|
-
});
|
|
1904
|
-
Assertion.addProperty("true", function() {
|
|
1905
|
-
this.assert(flag2(this, "object") === true, "expected #{this} to be true", "expected #{this} to be false", flag2(this, "negate") ? false : true);
|
|
1906
|
-
});
|
|
1907
|
-
Assertion.addProperty("numeric", function() {
|
|
1908
|
-
const object = flag2(this, "object");
|
|
1909
|
-
this.assert(["Number", "BigInt"].includes(type(object)), "expected #{this} to be numeric", "expected #{this} to not be numeric", flag2(this, "negate") ? false : true);
|
|
1910
|
-
});
|
|
1911
|
-
Assertion.addProperty("callable", function() {
|
|
1912
|
-
const val = flag2(this, "object");
|
|
1913
|
-
const ssfi = flag2(this, "ssfi");
|
|
1914
|
-
const message = flag2(this, "message");
|
|
1915
|
-
const msg = message ? `${message}: ` : "";
|
|
1916
|
-
const negate = flag2(this, "negate");
|
|
1917
|
-
const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
|
|
1918
|
-
const isCallable = [
|
|
1919
|
-
"Function",
|
|
1920
|
-
"AsyncFunction",
|
|
1921
|
-
"GeneratorFunction",
|
|
1922
|
-
"AsyncGeneratorFunction"
|
|
1923
|
-
].includes(type(val));
|
|
1924
|
-
if (isCallable && negate || !isCallable && !negate) {
|
|
1925
|
-
throw new AssertionError(assertionMessage, undefined, ssfi);
|
|
1926
|
-
}
|
|
1927
|
-
});
|
|
1928
|
-
Assertion.addProperty("false", function() {
|
|
1929
|
-
this.assert(flag2(this, "object") === false, "expected #{this} to be false", "expected #{this} to be true", flag2(this, "negate") ? true : false);
|
|
1930
|
-
});
|
|
1931
|
-
Assertion.addProperty("null", function() {
|
|
1932
|
-
this.assert(flag2(this, "object") === null, "expected #{this} to be null", "expected #{this} not to be null");
|
|
1933
|
-
});
|
|
1934
|
-
Assertion.addProperty("undefined", function() {
|
|
1935
|
-
this.assert(flag2(this, "object") === undefined, "expected #{this} to be undefined", "expected #{this} not to be undefined");
|
|
1936
|
-
});
|
|
1937
|
-
Assertion.addProperty("NaN", function() {
|
|
1938
|
-
this.assert(isNaN2(flag2(this, "object")), "expected #{this} to be NaN", "expected #{this} not to be NaN");
|
|
1939
|
-
});
|
|
1940
|
-
function assertExist() {
|
|
1941
|
-
let val = flag2(this, "object");
|
|
1942
|
-
this.assert(val !== null && val !== undefined, "expected #{this} to exist", "expected #{this} to not exist");
|
|
1943
|
-
}
|
|
1944
|
-
__name(assertExist, "assertExist");
|
|
1945
|
-
Assertion.addProperty("exist", assertExist);
|
|
1946
|
-
Assertion.addProperty("exists", assertExist);
|
|
1947
|
-
Assertion.addProperty("empty", function() {
|
|
1948
|
-
let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
1949
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
1950
|
-
switch (type(val).toLowerCase()) {
|
|
1951
|
-
case "array":
|
|
1952
|
-
case "string":
|
|
1953
|
-
itemsCount = val.length;
|
|
1954
|
-
break;
|
|
1955
|
-
case "map":
|
|
1956
|
-
case "set":
|
|
1957
|
-
itemsCount = val.size;
|
|
1958
|
-
break;
|
|
1959
|
-
case "weakmap":
|
|
1960
|
-
case "weakset":
|
|
1961
|
-
throw new AssertionError(flagMsg + ".empty was passed a weak collection", undefined, ssfi);
|
|
1962
|
-
case "function": {
|
|
1963
|
-
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
1964
|
-
throw new AssertionError(msg.trim(), undefined, ssfi);
|
|
1965
|
-
}
|
|
1966
|
-
default:
|
|
1967
|
-
if (val !== Object(val)) {
|
|
1968
|
-
throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), undefined, ssfi);
|
|
1969
|
-
}
|
|
1970
|
-
itemsCount = Object.keys(val).length;
|
|
1971
|
-
}
|
|
1972
|
-
this.assert(itemsCount === 0, "expected #{this} to be empty", "expected #{this} not to be empty");
|
|
1973
|
-
});
|
|
1974
|
-
function checkArguments() {
|
|
1975
|
-
let obj = flag2(this, "object"), type3 = type(obj);
|
|
1976
|
-
this.assert(type3 === "Arguments", "expected #{this} to be arguments but got " + type3, "expected #{this} to not be arguments");
|
|
1977
|
-
}
|
|
1978
|
-
__name(checkArguments, "checkArguments");
|
|
1979
|
-
Assertion.addProperty("arguments", checkArguments);
|
|
1980
|
-
Assertion.addProperty("Arguments", checkArguments);
|
|
1981
|
-
function assertEqual(val, msg) {
|
|
1982
|
-
if (msg)
|
|
1983
|
-
flag2(this, "message", msg);
|
|
1984
|
-
let obj = flag2(this, "object");
|
|
1985
|
-
if (flag2(this, "deep")) {
|
|
1986
|
-
let prevLockSsfi = flag2(this, "lockSsfi");
|
|
1987
|
-
flag2(this, "lockSsfi", true);
|
|
1988
|
-
this.eql(val);
|
|
1989
|
-
flag2(this, "lockSsfi", prevLockSsfi);
|
|
1990
|
-
} else {
|
|
1991
|
-
this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
__name(assertEqual, "assertEqual");
|
|
1995
|
-
Assertion.addMethod("equal", assertEqual);
|
|
1996
|
-
Assertion.addMethod("equals", assertEqual);
|
|
1997
|
-
Assertion.addMethod("eq", assertEqual);
|
|
1998
|
-
function assertEql(obj, msg) {
|
|
1999
|
-
if (msg)
|
|
2000
|
-
flag2(this, "message", msg);
|
|
2001
|
-
let eql = flag2(this, "eql");
|
|
2002
|
-
this.assert(eql(obj, flag2(this, "object")), "expected #{this} to deeply equal #{exp}", "expected #{this} to not deeply equal #{exp}", obj, this._obj, true);
|
|
2003
|
-
}
|
|
2004
|
-
__name(assertEql, "assertEql");
|
|
2005
|
-
Assertion.addMethod("eql", assertEql);
|
|
2006
|
-
Assertion.addMethod("eqls", assertEql);
|
|
2007
|
-
function assertAbove(n, msg) {
|
|
2008
|
-
if (msg)
|
|
2009
|
-
flag2(this, "message", msg);
|
|
2010
|
-
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();
|
|
2011
|
-
if (doLength && objType !== "map" && objType !== "set") {
|
|
2012
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2013
|
-
}
|
|
2014
|
-
if (!doLength && objType === "date" && nType !== "date") {
|
|
2015
|
-
throw new AssertionError(msgPrefix + "the argument to above must be a date", undefined, ssfi);
|
|
2016
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2017
|
-
throw new AssertionError(msgPrefix + "the argument to above must be a number", undefined, ssfi);
|
|
2018
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2019
|
-
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2020
|
-
throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", undefined, ssfi);
|
|
2021
|
-
}
|
|
2022
|
-
if (doLength) {
|
|
2023
|
-
let descriptor = "length", itemsCount;
|
|
2024
|
-
if (objType === "map" || objType === "set") {
|
|
2025
|
-
descriptor = "size";
|
|
2026
|
-
itemsCount = obj.size;
|
|
2027
|
-
} else {
|
|
2028
|
-
itemsCount = obj.length;
|
|
2029
|
-
}
|
|
2030
|
-
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);
|
|
2031
|
-
} else {
|
|
2032
|
-
this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
__name(assertAbove, "assertAbove");
|
|
2036
|
-
Assertion.addMethod("above", assertAbove);
|
|
2037
|
-
Assertion.addMethod("gt", assertAbove);
|
|
2038
|
-
Assertion.addMethod("greaterThan", assertAbove);
|
|
2039
|
-
function assertLeast(n, msg) {
|
|
2040
|
-
if (msg)
|
|
2041
|
-
flag2(this, "message", msg);
|
|
2042
|
-
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;
|
|
2043
|
-
if (doLength && objType !== "map" && objType !== "set") {
|
|
2044
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2045
|
-
}
|
|
2046
|
-
if (!doLength && objType === "date" && nType !== "date") {
|
|
2047
|
-
errorMessage = msgPrefix + "the argument to least must be a date";
|
|
2048
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2049
|
-
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2050
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2051
|
-
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2052
|
-
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2053
|
-
} else {
|
|
2054
|
-
shouldThrow = false;
|
|
2055
|
-
}
|
|
2056
|
-
if (shouldThrow) {
|
|
2057
|
-
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
2058
|
-
}
|
|
2059
|
-
if (doLength) {
|
|
2060
|
-
let descriptor = "length", itemsCount;
|
|
2061
|
-
if (objType === "map" || objType === "set") {
|
|
2062
|
-
descriptor = "size";
|
|
2063
|
-
itemsCount = obj.size;
|
|
2064
|
-
} else {
|
|
2065
|
-
itemsCount = obj.length;
|
|
2066
|
-
}
|
|
2067
|
-
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);
|
|
2068
|
-
} else {
|
|
2069
|
-
this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
__name(assertLeast, "assertLeast");
|
|
2073
|
-
Assertion.addMethod("least", assertLeast);
|
|
2074
|
-
Assertion.addMethod("gte", assertLeast);
|
|
2075
|
-
Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
2076
|
-
function assertBelow(n, msg) {
|
|
2077
|
-
if (msg)
|
|
2078
|
-
flag2(this, "message", msg);
|
|
2079
|
-
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;
|
|
2080
|
-
if (doLength && objType !== "map" && objType !== "set") {
|
|
2081
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2082
|
-
}
|
|
2083
|
-
if (!doLength && objType === "date" && nType !== "date") {
|
|
2084
|
-
errorMessage = msgPrefix + "the argument to below must be a date";
|
|
2085
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2086
|
-
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2087
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2088
|
-
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2089
|
-
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2090
|
-
} else {
|
|
2091
|
-
shouldThrow = false;
|
|
2092
|
-
}
|
|
2093
|
-
if (shouldThrow) {
|
|
2094
|
-
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
2095
|
-
}
|
|
2096
|
-
if (doLength) {
|
|
2097
|
-
let descriptor = "length", itemsCount;
|
|
2098
|
-
if (objType === "map" || objType === "set") {
|
|
2099
|
-
descriptor = "size";
|
|
2100
|
-
itemsCount = obj.size;
|
|
2101
|
-
} else {
|
|
2102
|
-
itemsCount = obj.length;
|
|
2103
|
-
}
|
|
2104
|
-
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);
|
|
2105
|
-
} else {
|
|
2106
|
-
this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
__name(assertBelow, "assertBelow");
|
|
2110
|
-
Assertion.addMethod("below", assertBelow);
|
|
2111
|
-
Assertion.addMethod("lt", assertBelow);
|
|
2112
|
-
Assertion.addMethod("lessThan", assertBelow);
|
|
2113
|
-
function assertMost(n, msg) {
|
|
2114
|
-
if (msg)
|
|
2115
|
-
flag2(this, "message", msg);
|
|
2116
|
-
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;
|
|
2117
|
-
if (doLength && objType !== "map" && objType !== "set") {
|
|
2118
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2119
|
-
}
|
|
2120
|
-
if (!doLength && objType === "date" && nType !== "date") {
|
|
2121
|
-
errorMessage = msgPrefix + "the argument to most must be a date";
|
|
2122
|
-
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2123
|
-
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2124
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2125
|
-
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2126
|
-
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2127
|
-
} else {
|
|
2128
|
-
shouldThrow = false;
|
|
2129
|
-
}
|
|
2130
|
-
if (shouldThrow) {
|
|
2131
|
-
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
2132
|
-
}
|
|
2133
|
-
if (doLength) {
|
|
2134
|
-
let descriptor = "length", itemsCount;
|
|
2135
|
-
if (objType === "map" || objType === "set") {
|
|
2136
|
-
descriptor = "size";
|
|
2137
|
-
itemsCount = obj.size;
|
|
2138
|
-
} else {
|
|
2139
|
-
itemsCount = obj.length;
|
|
2140
|
-
}
|
|
2141
|
-
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);
|
|
2142
|
-
} else {
|
|
2143
|
-
this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
__name(assertMost, "assertMost");
|
|
2147
|
-
Assertion.addMethod("most", assertMost);
|
|
2148
|
-
Assertion.addMethod("lte", assertMost);
|
|
2149
|
-
Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
2150
|
-
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2151
|
-
if (msg)
|
|
2152
|
-
flag2(this, "message", msg);
|
|
2153
|
-
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;
|
|
2154
|
-
if (doLength && objType !== "map" && objType !== "set") {
|
|
2155
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2156
|
-
}
|
|
2157
|
-
if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) {
|
|
2158
|
-
errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
2159
|
-
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2160
|
-
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2161
|
-
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2162
|
-
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2163
|
-
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2164
|
-
} else {
|
|
2165
|
-
shouldThrow = false;
|
|
2166
|
-
}
|
|
2167
|
-
if (shouldThrow) {
|
|
2168
|
-
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
2169
|
-
}
|
|
2170
|
-
if (doLength) {
|
|
2171
|
-
let descriptor = "length", itemsCount;
|
|
2172
|
-
if (objType === "map" || objType === "set") {
|
|
2173
|
-
descriptor = "size";
|
|
2174
|
-
itemsCount = obj.size;
|
|
2175
|
-
} else {
|
|
2176
|
-
itemsCount = obj.length;
|
|
2177
|
-
}
|
|
2178
|
-
this.assert(itemsCount >= start && itemsCount <= finish, "expected #{this} to have a " + descriptor + " within " + range, "expected #{this} to not have a " + descriptor + " within " + range);
|
|
2179
|
-
} else {
|
|
2180
|
-
this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
|
|
2181
|
-
}
|
|
2182
|
-
});
|
|
2183
|
-
function assertInstanceOf(constructor, msg) {
|
|
2184
|
-
if (msg)
|
|
2185
|
-
flag2(this, "message", msg);
|
|
2186
|
-
let target = flag2(this, "object");
|
|
2187
|
-
let ssfi = flag2(this, "ssfi");
|
|
2188
|
-
let flagMsg = flag2(this, "message");
|
|
2189
|
-
let isInstanceOf;
|
|
2190
|
-
try {
|
|
2191
|
-
isInstanceOf = target instanceof constructor;
|
|
2192
|
-
} catch (err) {
|
|
2193
|
-
if (err instanceof TypeError) {
|
|
2194
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2195
|
-
throw new AssertionError(flagMsg + "The instanceof assertion needs a constructor but " + type(constructor) + " was given.", undefined, ssfi);
|
|
2196
|
-
}
|
|
2197
|
-
throw err;
|
|
2198
|
-
}
|
|
2199
|
-
let name = getName(constructor);
|
|
2200
|
-
if (name == null) {
|
|
2201
|
-
name = "an unnamed constructor";
|
|
2202
|
-
}
|
|
2203
|
-
this.assert(isInstanceOf, "expected #{this} to be an instance of " + name, "expected #{this} to not be an instance of " + name);
|
|
2204
|
-
}
|
|
2205
|
-
__name(assertInstanceOf, "assertInstanceOf");
|
|
2206
|
-
Assertion.addMethod("instanceof", assertInstanceOf);
|
|
2207
|
-
Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
2208
|
-
function assertProperty(name, val, msg) {
|
|
2209
|
-
if (msg)
|
|
2210
|
-
flag2(this, "message", msg);
|
|
2211
|
-
let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2212
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2213
|
-
if (isNested) {
|
|
2214
|
-
if (nameType !== "string") {
|
|
2215
|
-
throw new AssertionError(flagMsg + "the argument to property must be a string when using nested syntax", undefined, ssfi);
|
|
2216
|
-
}
|
|
2217
|
-
} else {
|
|
2218
|
-
if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") {
|
|
2219
|
-
throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", undefined, ssfi);
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
if (isNested && isOwn) {
|
|
2223
|
-
throw new AssertionError(flagMsg + 'The "nested" and "own" flags cannot be combined.', undefined, ssfi);
|
|
2224
|
-
}
|
|
2225
|
-
if (obj === null || obj === undefined) {
|
|
2226
|
-
throw new AssertionError(flagMsg + "Target cannot be null or undefined.", undefined, ssfi);
|
|
2227
|
-
}
|
|
2228
|
-
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;
|
|
2229
|
-
let descriptor = "";
|
|
2230
|
-
if (isDeep)
|
|
2231
|
-
descriptor += "deep ";
|
|
2232
|
-
if (isOwn)
|
|
2233
|
-
descriptor += "own ";
|
|
2234
|
-
if (isNested)
|
|
2235
|
-
descriptor += "nested ";
|
|
2236
|
-
descriptor += "property ";
|
|
2237
|
-
let hasProperty2;
|
|
2238
|
-
if (isOwn)
|
|
2239
|
-
hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
|
|
2240
|
-
else if (isNested)
|
|
2241
|
-
hasProperty2 = pathInfo.exists;
|
|
2242
|
-
else
|
|
2243
|
-
hasProperty2 = hasProperty(obj, name);
|
|
2244
|
-
if (!negate || arguments.length === 1) {
|
|
2245
|
-
this.assert(hasProperty2, "expected #{this} to have " + descriptor + inspect2(name), "expected #{this} to not have " + descriptor + inspect2(name));
|
|
2246
|
-
}
|
|
2247
|
-
if (arguments.length > 1) {
|
|
2248
|
-
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);
|
|
2249
|
-
}
|
|
2250
|
-
flag2(this, "object", value);
|
|
2251
|
-
}
|
|
2252
|
-
__name(assertProperty, "assertProperty");
|
|
2253
|
-
Assertion.addMethod("property", assertProperty);
|
|
2254
|
-
function assertOwnProperty(_name, _value, _msg) {
|
|
2255
|
-
flag2(this, "own", true);
|
|
2256
|
-
assertProperty.apply(this, arguments);
|
|
2257
|
-
}
|
|
2258
|
-
__name(assertOwnProperty, "assertOwnProperty");
|
|
2259
|
-
Assertion.addMethod("ownProperty", assertOwnProperty);
|
|
2260
|
-
Assertion.addMethod("haveOwnProperty", assertOwnProperty);
|
|
2261
|
-
function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
2262
|
-
if (typeof descriptor === "string") {
|
|
2263
|
-
msg = descriptor;
|
|
2264
|
-
descriptor = null;
|
|
2265
|
-
}
|
|
2266
|
-
if (msg)
|
|
2267
|
-
flag2(this, "message", msg);
|
|
2268
|
-
let obj = flag2(this, "object");
|
|
2269
|
-
let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
2270
|
-
let eql = flag2(this, "eql");
|
|
2271
|
-
if (actualDescriptor && descriptor) {
|
|
2272
|
-
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);
|
|
2273
|
-
} else {
|
|
2274
|
-
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));
|
|
2275
|
-
}
|
|
2276
|
-
flag2(this, "object", actualDescriptor);
|
|
2277
|
-
}
|
|
2278
|
-
__name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
|
|
2279
|
-
Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
2280
|
-
Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
2281
|
-
function assertLengthChain() {
|
|
2282
|
-
flag2(this, "doLength", true);
|
|
2283
|
-
}
|
|
2284
|
-
__name(assertLengthChain, "assertLengthChain");
|
|
2285
|
-
function assertLength(n, msg) {
|
|
2286
|
-
if (msg)
|
|
2287
|
-
flag2(this, "message", msg);
|
|
2288
|
-
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
2289
|
-
switch (objType) {
|
|
2290
|
-
case "map":
|
|
2291
|
-
case "set":
|
|
2292
|
-
descriptor = "size";
|
|
2293
|
-
itemsCount = obj.size;
|
|
2294
|
-
break;
|
|
2295
|
-
default:
|
|
2296
|
-
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2297
|
-
itemsCount = obj.length;
|
|
2298
|
-
}
|
|
2299
|
-
this.assert(itemsCount == n, "expected #{this} to have a " + descriptor + " of #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " of #{act}", n, itemsCount);
|
|
2300
|
-
}
|
|
2301
|
-
__name(assertLength, "assertLength");
|
|
2302
|
-
Assertion.addChainableMethod("length", assertLength, assertLengthChain);
|
|
2303
|
-
Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
2304
|
-
function assertMatch(re, msg) {
|
|
2305
|
-
if (msg)
|
|
2306
|
-
flag2(this, "message", msg);
|
|
2307
|
-
let obj = flag2(this, "object");
|
|
2308
|
-
this.assert(re.exec(obj), "expected #{this} to match " + re, "expected #{this} not to match " + re);
|
|
2309
|
-
}
|
|
2310
|
-
__name(assertMatch, "assertMatch");
|
|
2311
|
-
Assertion.addMethod("match", assertMatch);
|
|
2312
|
-
Assertion.addMethod("matches", assertMatch);
|
|
2313
|
-
Assertion.addMethod("string", function(str, msg) {
|
|
2314
|
-
if (msg)
|
|
2315
|
-
flag2(this, "message", msg);
|
|
2316
|
-
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2317
|
-
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
2318
|
-
this.assert(~obj.indexOf(str), "expected #{this} to contain " + inspect2(str), "expected #{this} to not contain " + inspect2(str));
|
|
2319
|
-
});
|
|
2320
|
-
function assertKeys(keys) {
|
|
2321
|
-
let obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
|
|
2322
|
-
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2323
|
-
let mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
|
|
2324
|
-
if (objType === "Map" || objType === "Set") {
|
|
2325
|
-
deepStr = isDeep ? "deeply " : "";
|
|
2326
|
-
actual = [];
|
|
2327
|
-
obj.forEach(function(val, key) {
|
|
2328
|
-
actual.push(key);
|
|
2329
|
-
});
|
|
2330
|
-
if (keysType !== "Array") {
|
|
2331
|
-
keys = Array.prototype.slice.call(arguments);
|
|
2332
|
-
}
|
|
2333
|
-
} else {
|
|
2334
|
-
actual = getOwnEnumerableProperties(obj);
|
|
2335
|
-
switch (keysType) {
|
|
2336
|
-
case "Array":
|
|
2337
|
-
if (arguments.length > 1) {
|
|
2338
|
-
throw new AssertionError(mixedArgsMsg, undefined, ssfi);
|
|
2339
|
-
}
|
|
2340
|
-
break;
|
|
2341
|
-
case "Object":
|
|
2342
|
-
if (arguments.length > 1) {
|
|
2343
|
-
throw new AssertionError(mixedArgsMsg, undefined, ssfi);
|
|
2344
|
-
}
|
|
2345
|
-
keys = Object.keys(keys);
|
|
2346
|
-
break;
|
|
2347
|
-
default:
|
|
2348
|
-
keys = Array.prototype.slice.call(arguments);
|
|
2349
|
-
}
|
|
2350
|
-
keys = keys.map(function(val) {
|
|
2351
|
-
return typeof val === "symbol" ? val : String(val);
|
|
2352
|
-
});
|
|
2353
|
-
}
|
|
2354
|
-
if (!keys.length) {
|
|
2355
|
-
throw new AssertionError(flagMsg + "keys required", undefined, ssfi);
|
|
2356
|
-
}
|
|
2357
|
-
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2358
|
-
if (!any && !all) {
|
|
2359
|
-
all = true;
|
|
2360
|
-
}
|
|
2361
|
-
if (any) {
|
|
2362
|
-
ok = expected.some(function(expectedKey) {
|
|
2363
|
-
return actual.some(function(actualKey) {
|
|
2364
|
-
return isEql(expectedKey, actualKey);
|
|
2365
|
-
});
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
if (all) {
|
|
2369
|
-
ok = expected.every(function(expectedKey) {
|
|
2370
|
-
return actual.some(function(actualKey) {
|
|
2371
|
-
return isEql(expectedKey, actualKey);
|
|
2372
|
-
});
|
|
2373
|
-
});
|
|
2374
|
-
if (!flag2(this, "contains")) {
|
|
2375
|
-
ok = ok && keys.length == actual.length;
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
if (len > 1) {
|
|
2379
|
-
keys = keys.map(function(key) {
|
|
2380
|
-
return inspect2(key);
|
|
2381
|
-
});
|
|
2382
|
-
let last = keys.pop();
|
|
2383
|
-
if (all) {
|
|
2384
|
-
str = keys.join(", ") + ", and " + last;
|
|
2385
|
-
}
|
|
2386
|
-
if (any) {
|
|
2387
|
-
str = keys.join(", ") + ", or " + last;
|
|
2388
|
-
}
|
|
2389
|
-
} else {
|
|
2390
|
-
str = inspect2(keys[0]);
|
|
2391
|
-
}
|
|
2392
|
-
str = (len > 1 ? "keys " : "key ") + str;
|
|
2393
|
-
str = (flag2(this, "contains") ? "contain " : "have ") + str;
|
|
2394
|
-
this.assert(ok, "expected #{this} to " + deepStr + str, "expected #{this} to not " + deepStr + str, expected.slice(0).sort(compareByInspect), actual.sort(compareByInspect), true);
|
|
2395
|
-
}
|
|
2396
|
-
__name(assertKeys, "assertKeys");
|
|
2397
|
-
Assertion.addMethod("keys", assertKeys);
|
|
2398
|
-
Assertion.addMethod("key", assertKeys);
|
|
2399
|
-
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
2400
|
-
if (msg)
|
|
2401
|
-
flag2(this, "message", msg);
|
|
2402
|
-
let obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
2403
|
-
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
2404
|
-
if (isRegExp2(errorLike) || typeof errorLike === "string") {
|
|
2405
|
-
errMsgMatcher = errorLike;
|
|
2406
|
-
errorLike = null;
|
|
2407
|
-
}
|
|
2408
|
-
let caughtErr;
|
|
2409
|
-
let errorWasThrown = false;
|
|
2410
|
-
try {
|
|
2411
|
-
obj();
|
|
2412
|
-
} catch (err) {
|
|
2413
|
-
errorWasThrown = true;
|
|
2414
|
-
caughtErr = err;
|
|
2415
|
-
}
|
|
2416
|
-
let everyArgIsUndefined = errorLike === undefined && errMsgMatcher === undefined;
|
|
2417
|
-
let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
2418
|
-
let errorLikeFail = false;
|
|
2419
|
-
let errMsgMatcherFail = false;
|
|
2420
|
-
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
2421
|
-
let errorLikeString = "an error";
|
|
2422
|
-
if (errorLike instanceof Error) {
|
|
2423
|
-
errorLikeString = "#{exp}";
|
|
2424
|
-
} else if (errorLike) {
|
|
2425
|
-
errorLikeString = check_error_exports.getConstructorName(errorLike);
|
|
2426
|
-
}
|
|
2427
|
-
let actual = caughtErr;
|
|
2428
|
-
if (caughtErr instanceof Error) {
|
|
2429
|
-
actual = caughtErr.toString();
|
|
2430
|
-
} else if (typeof caughtErr === "string") {
|
|
2431
|
-
actual = caughtErr;
|
|
2432
|
-
} else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) {
|
|
2433
|
-
try {
|
|
2434
|
-
actual = check_error_exports.getConstructorName(caughtErr);
|
|
2435
|
-
} catch (_err) {}
|
|
2436
|
-
}
|
|
2437
|
-
this.assert(errorWasThrown, "expected #{this} to throw " + errorLikeString, "expected #{this} to not throw an error but #{act} was thrown", errorLike && errorLike.toString(), actual);
|
|
2438
|
-
}
|
|
2439
|
-
if (errorLike && caughtErr) {
|
|
2440
|
-
if (errorLike instanceof Error) {
|
|
2441
|
-
let isCompatibleInstance = check_error_exports.compatibleInstance(caughtErr, errorLike);
|
|
2442
|
-
if (isCompatibleInstance === negate) {
|
|
2443
|
-
if (everyArgIsDefined && negate) {
|
|
2444
|
-
errorLikeFail = true;
|
|
2445
|
-
} else {
|
|
2446
|
-
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());
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
let isCompatibleConstructor = check_error_exports.compatibleConstructor(caughtErr, errorLike);
|
|
2451
|
-
if (isCompatibleConstructor === negate) {
|
|
2452
|
-
if (everyArgIsDefined && negate) {
|
|
2453
|
-
errorLikeFail = true;
|
|
2454
|
-
} else {
|
|
2455
|
-
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));
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
if (caughtErr && errMsgMatcher !== undefined && errMsgMatcher !== null) {
|
|
2460
|
-
let placeholder = "including";
|
|
2461
|
-
if (isRegExp2(errMsgMatcher)) {
|
|
2462
|
-
placeholder = "matching";
|
|
2463
|
-
}
|
|
2464
|
-
let isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
|
|
2465
|
-
if (isCompatibleMessage === negate) {
|
|
2466
|
-
if (everyArgIsDefined && negate) {
|
|
2467
|
-
errMsgMatcherFail = true;
|
|
2468
|
-
} else {
|
|
2469
|
-
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));
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
if (errorLikeFail && errMsgMatcherFail) {
|
|
2474
|
-
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));
|
|
2475
|
-
}
|
|
2476
|
-
flag2(this, "object", caughtErr);
|
|
2477
|
-
}
|
|
2478
|
-
__name(assertThrows, "assertThrows");
|
|
2479
|
-
Assertion.addMethod("throw", assertThrows);
|
|
2480
|
-
Assertion.addMethod("throws", assertThrows);
|
|
2481
|
-
Assertion.addMethod("Throw", assertThrows);
|
|
2482
|
-
function respondTo(method, msg) {
|
|
2483
|
-
if (msg)
|
|
2484
|
-
flag2(this, "message", msg);
|
|
2485
|
-
let obj = flag2(this, "object"), itself = flag2(this, "itself"), context = typeof obj === "function" && !itself ? obj.prototype[method] : obj[method];
|
|
2486
|
-
this.assert(typeof context === "function", "expected #{this} to respond to " + inspect2(method), "expected #{this} to not respond to " + inspect2(method));
|
|
2487
|
-
}
|
|
2488
|
-
__name(respondTo, "respondTo");
|
|
2489
|
-
Assertion.addMethod("respondTo", respondTo);
|
|
2490
|
-
Assertion.addMethod("respondsTo", respondTo);
|
|
2491
|
-
Assertion.addProperty("itself", function() {
|
|
2492
|
-
flag2(this, "itself", true);
|
|
2493
|
-
});
|
|
2494
|
-
function satisfy(matcher, msg) {
|
|
2495
|
-
if (msg)
|
|
2496
|
-
flag2(this, "message", msg);
|
|
2497
|
-
let obj = flag2(this, "object");
|
|
2498
|
-
let result = matcher(obj);
|
|
2499
|
-
this.assert(result, "expected #{this} to satisfy " + objDisplay(matcher), "expected #{this} to not satisfy" + objDisplay(matcher), flag2(this, "negate") ? false : true, result);
|
|
2500
|
-
}
|
|
2501
|
-
__name(satisfy, "satisfy");
|
|
2502
|
-
Assertion.addMethod("satisfy", satisfy);
|
|
2503
|
-
Assertion.addMethod("satisfies", satisfy);
|
|
2504
|
-
function closeTo(expected, delta, msg) {
|
|
2505
|
-
if (msg)
|
|
2506
|
-
flag2(this, "message", msg);
|
|
2507
|
-
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2508
|
-
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
2509
|
-
let message = "A `delta` value is required for `closeTo`";
|
|
2510
|
-
if (delta == undefined) {
|
|
2511
|
-
throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, undefined, ssfi);
|
|
2512
|
-
}
|
|
2513
|
-
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
2514
|
-
message = "A `expected` value is required for `closeTo`";
|
|
2515
|
-
if (expected == undefined) {
|
|
2516
|
-
throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, undefined, ssfi);
|
|
2517
|
-
}
|
|
2518
|
-
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
2519
|
-
const abs = /* @__PURE__ */ __name((x) => x < 0 ? -x : x, "abs");
|
|
2520
|
-
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
2521
|
-
this.assert(strip(abs(obj - expected)) <= delta, "expected #{this} to be close to " + expected + " +/- " + delta, "expected #{this} not to be close to " + expected + " +/- " + delta);
|
|
2522
|
-
}
|
|
2523
|
-
__name(closeTo, "closeTo");
|
|
2524
|
-
Assertion.addMethod("closeTo", closeTo);
|
|
2525
|
-
Assertion.addMethod("approximately", closeTo);
|
|
2526
|
-
function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
|
|
2527
|
-
let superset = Array.from(_superset);
|
|
2528
|
-
let subset = Array.from(_subset);
|
|
2529
|
-
if (!contains) {
|
|
2530
|
-
if (subset.length !== superset.length)
|
|
2531
|
-
return false;
|
|
2532
|
-
superset = superset.slice();
|
|
2533
|
-
}
|
|
2534
|
-
return subset.every(function(elem, idx) {
|
|
2535
|
-
if (ordered)
|
|
2536
|
-
return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
2537
|
-
if (!cmp) {
|
|
2538
|
-
let matchIdx = superset.indexOf(elem);
|
|
2539
|
-
if (matchIdx === -1)
|
|
2540
|
-
return false;
|
|
2541
|
-
if (!contains)
|
|
2542
|
-
superset.splice(matchIdx, 1);
|
|
2543
|
-
return true;
|
|
2544
|
-
}
|
|
2545
|
-
return superset.some(function(elem2, matchIdx) {
|
|
2546
|
-
if (!cmp(elem, elem2))
|
|
2547
|
-
return false;
|
|
2548
|
-
if (!contains)
|
|
2549
|
-
superset.splice(matchIdx, 1);
|
|
2550
|
-
return true;
|
|
2551
|
-
});
|
|
2552
|
-
});
|
|
2553
|
-
}
|
|
2554
|
-
__name(isSubsetOf, "isSubsetOf");
|
|
2555
|
-
Assertion.addMethod("members", function(subset, msg) {
|
|
2556
|
-
if (msg)
|
|
2557
|
-
flag2(this, "message", msg);
|
|
2558
|
-
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2559
|
-
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
|
|
2560
|
-
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
|
|
2561
|
-
let contains = flag2(this, "contains");
|
|
2562
|
-
let ordered = flag2(this, "ordered");
|
|
2563
|
-
let subject, failMsg, failNegateMsg;
|
|
2564
|
-
if (contains) {
|
|
2565
|
-
subject = ordered ? "an ordered superset" : "a superset";
|
|
2566
|
-
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
2567
|
-
failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
|
|
2568
|
-
} else {
|
|
2569
|
-
subject = ordered ? "ordered members" : "members";
|
|
2570
|
-
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
2571
|
-
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
2572
|
-
}
|
|
2573
|
-
let cmp = flag2(this, "deep") ? flag2(this, "eql") : undefined;
|
|
2574
|
-
this.assert(isSubsetOf(subset, obj, cmp, contains, ordered), failMsg, failNegateMsg, subset, obj, true);
|
|
2575
|
-
});
|
|
2576
|
-
Assertion.addProperty("iterable", function(msg) {
|
|
2577
|
-
if (msg)
|
|
2578
|
-
flag2(this, "message", msg);
|
|
2579
|
-
let obj = flag2(this, "object");
|
|
2580
|
-
this.assert(obj != null && obj[Symbol.iterator], "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
|
|
2581
|
-
});
|
|
2582
|
-
function oneOf(list, msg) {
|
|
2583
|
-
if (msg)
|
|
2584
|
-
flag2(this, "message", msg);
|
|
2585
|
-
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");
|
|
2586
|
-
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
2587
|
-
if (contains) {
|
|
2588
|
-
this.assert(list.some(function(possibility) {
|
|
2589
|
-
return expected.indexOf(possibility) > -1;
|
|
2590
|
-
}), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
|
|
2591
|
-
} else {
|
|
2592
|
-
if (isDeep) {
|
|
2593
|
-
this.assert(list.some(function(possibility) {
|
|
2594
|
-
return eql(expected, possibility);
|
|
2595
|
-
}), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
|
|
2596
|
-
} else {
|
|
2597
|
-
this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
__name(oneOf, "oneOf");
|
|
2602
|
-
Assertion.addMethod("oneOf", oneOf);
|
|
2603
|
-
function assertChanges(subject, prop, msg) {
|
|
2604
|
-
if (msg)
|
|
2605
|
-
flag2(this, "message", msg);
|
|
2606
|
-
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2607
|
-
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
2608
|
-
let initial;
|
|
2609
|
-
if (!prop) {
|
|
2610
|
-
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
2611
|
-
initial = subject();
|
|
2612
|
-
} else {
|
|
2613
|
-
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
2614
|
-
initial = subject[prop];
|
|
2615
|
-
}
|
|
2616
|
-
fn();
|
|
2617
|
-
let final = prop === undefined || prop === null ? subject() : subject[prop];
|
|
2618
|
-
let msgObj = prop === undefined || prop === null ? initial : "." + prop;
|
|
2619
|
-
flag2(this, "deltaMsgObj", msgObj);
|
|
2620
|
-
flag2(this, "initialDeltaValue", initial);
|
|
2621
|
-
flag2(this, "finalDeltaValue", final);
|
|
2622
|
-
flag2(this, "deltaBehavior", "change");
|
|
2623
|
-
flag2(this, "realDelta", final !== initial);
|
|
2624
|
-
this.assert(initial !== final, "expected " + msgObj + " to change", "expected " + msgObj + " to not change");
|
|
2625
|
-
}
|
|
2626
|
-
__name(assertChanges, "assertChanges");
|
|
2627
|
-
Assertion.addMethod("change", assertChanges);
|
|
2628
|
-
Assertion.addMethod("changes", assertChanges);
|
|
2629
|
-
function assertIncreases(subject, prop, msg) {
|
|
2630
|
-
if (msg)
|
|
2631
|
-
flag2(this, "message", msg);
|
|
2632
|
-
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2633
|
-
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
2634
|
-
let initial;
|
|
2635
|
-
if (!prop) {
|
|
2636
|
-
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
2637
|
-
initial = subject();
|
|
2638
|
-
} else {
|
|
2639
|
-
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
2640
|
-
initial = subject[prop];
|
|
2641
|
-
}
|
|
2642
|
-
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
2643
|
-
fn();
|
|
2644
|
-
let final = prop === undefined || prop === null ? subject() : subject[prop];
|
|
2645
|
-
let msgObj = prop === undefined || prop === null ? initial : "." + prop;
|
|
2646
|
-
flag2(this, "deltaMsgObj", msgObj);
|
|
2647
|
-
flag2(this, "initialDeltaValue", initial);
|
|
2648
|
-
flag2(this, "finalDeltaValue", final);
|
|
2649
|
-
flag2(this, "deltaBehavior", "increase");
|
|
2650
|
-
flag2(this, "realDelta", final - initial);
|
|
2651
|
-
this.assert(final - initial > 0, "expected " + msgObj + " to increase", "expected " + msgObj + " to not increase");
|
|
2652
|
-
}
|
|
2653
|
-
__name(assertIncreases, "assertIncreases");
|
|
2654
|
-
Assertion.addMethod("increase", assertIncreases);
|
|
2655
|
-
Assertion.addMethod("increases", assertIncreases);
|
|
2656
|
-
function assertDecreases(subject, prop, msg) {
|
|
2657
|
-
if (msg)
|
|
2658
|
-
flag2(this, "message", msg);
|
|
2659
|
-
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2660
|
-
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
2661
|
-
let initial;
|
|
2662
|
-
if (!prop) {
|
|
2663
|
-
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
2664
|
-
initial = subject();
|
|
2665
|
-
} else {
|
|
2666
|
-
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
2667
|
-
initial = subject[prop];
|
|
2668
|
-
}
|
|
2669
|
-
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
2670
|
-
fn();
|
|
2671
|
-
let final = prop === undefined || prop === null ? subject() : subject[prop];
|
|
2672
|
-
let msgObj = prop === undefined || prop === null ? initial : "." + prop;
|
|
2673
|
-
flag2(this, "deltaMsgObj", msgObj);
|
|
2674
|
-
flag2(this, "initialDeltaValue", initial);
|
|
2675
|
-
flag2(this, "finalDeltaValue", final);
|
|
2676
|
-
flag2(this, "deltaBehavior", "decrease");
|
|
2677
|
-
flag2(this, "realDelta", initial - final);
|
|
2678
|
-
this.assert(final - initial < 0, "expected " + msgObj + " to decrease", "expected " + msgObj + " to not decrease");
|
|
2679
|
-
}
|
|
2680
|
-
__name(assertDecreases, "assertDecreases");
|
|
2681
|
-
Assertion.addMethod("decrease", assertDecreases);
|
|
2682
|
-
Assertion.addMethod("decreases", assertDecreases);
|
|
2683
|
-
function assertDelta(delta, msg) {
|
|
2684
|
-
if (msg)
|
|
2685
|
-
flag2(this, "message", msg);
|
|
2686
|
-
let msgObj = flag2(this, "deltaMsgObj");
|
|
2687
|
-
let initial = flag2(this, "initialDeltaValue");
|
|
2688
|
-
let final = flag2(this, "finalDeltaValue");
|
|
2689
|
-
let behavior = flag2(this, "deltaBehavior");
|
|
2690
|
-
let realDelta = flag2(this, "realDelta");
|
|
2691
|
-
let expression;
|
|
2692
|
-
if (behavior === "change") {
|
|
2693
|
-
expression = Math.abs(final - initial) === Math.abs(delta);
|
|
2694
|
-
} else {
|
|
2695
|
-
expression = realDelta === Math.abs(delta);
|
|
2696
|
-
}
|
|
2697
|
-
this.assert(expression, "expected " + msgObj + " to " + behavior + " by " + delta, "expected " + msgObj + " to not " + behavior + " by " + delta);
|
|
2698
|
-
}
|
|
2699
|
-
__name(assertDelta, "assertDelta");
|
|
2700
|
-
Assertion.addMethod("by", assertDelta);
|
|
2701
|
-
Assertion.addProperty("extensible", function() {
|
|
2702
|
-
let obj = flag2(this, "object");
|
|
2703
|
-
let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
2704
|
-
this.assert(isExtensible, "expected #{this} to be extensible", "expected #{this} to not be extensible");
|
|
2705
|
-
});
|
|
2706
|
-
Assertion.addProperty("sealed", function() {
|
|
2707
|
-
let obj = flag2(this, "object");
|
|
2708
|
-
let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
2709
|
-
this.assert(isSealed, "expected #{this} to be sealed", "expected #{this} to not be sealed");
|
|
2710
|
-
});
|
|
2711
|
-
Assertion.addProperty("frozen", function() {
|
|
2712
|
-
let obj = flag2(this, "object");
|
|
2713
|
-
let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
2714
|
-
this.assert(isFrozen, "expected #{this} to be frozen", "expected #{this} to not be frozen");
|
|
2715
|
-
});
|
|
2716
|
-
Assertion.addProperty("finite", function(_msg) {
|
|
2717
|
-
let obj = flag2(this, "object");
|
|
2718
|
-
this.assert(typeof obj === "number" && isFinite(obj), "expected #{this} to be a finite number", "expected #{this} to not be a finite number");
|
|
2719
|
-
});
|
|
2720
|
-
function compareSubset(expected, actual) {
|
|
2721
|
-
if (expected === actual) {
|
|
2722
|
-
return true;
|
|
2723
|
-
}
|
|
2724
|
-
if (typeof actual !== typeof expected) {
|
|
2725
|
-
return false;
|
|
2726
|
-
}
|
|
2727
|
-
if (typeof expected !== "object" || expected === null) {
|
|
2728
|
-
return expected === actual;
|
|
2729
|
-
}
|
|
2730
|
-
if (!actual) {
|
|
2731
|
-
return false;
|
|
2732
|
-
}
|
|
2733
|
-
if (Array.isArray(expected)) {
|
|
2734
|
-
if (!Array.isArray(actual)) {
|
|
2735
|
-
return false;
|
|
2736
|
-
}
|
|
2737
|
-
return expected.every(function(exp) {
|
|
2738
|
-
return actual.some(function(act) {
|
|
2739
|
-
return compareSubset(exp, act);
|
|
2740
|
-
});
|
|
2741
|
-
});
|
|
2742
|
-
}
|
|
2743
|
-
if (expected instanceof Date) {
|
|
2744
|
-
if (actual instanceof Date) {
|
|
2745
|
-
return expected.getTime() === actual.getTime();
|
|
2746
|
-
} else {
|
|
2747
|
-
return false;
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
return Object.keys(expected).every(function(key) {
|
|
2751
|
-
let expectedValue = expected[key];
|
|
2752
|
-
let actualValue = actual[key];
|
|
2753
|
-
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
|
|
2754
|
-
return compareSubset(expectedValue, actualValue);
|
|
2755
|
-
}
|
|
2756
|
-
if (typeof expectedValue === "function") {
|
|
2757
|
-
return expectedValue(actualValue);
|
|
2758
|
-
}
|
|
2759
|
-
return actualValue === expectedValue;
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
|
-
__name(compareSubset, "compareSubset");
|
|
2763
|
-
Assertion.addMethod("containSubset", function(expected) {
|
|
2764
|
-
const actual = flag(this, "object");
|
|
2765
|
-
const showDiff = config.showDiff;
|
|
2766
|
-
this.assert(compareSubset(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
|
|
2767
|
-
});
|
|
2768
|
-
function expect(val, message) {
|
|
2769
|
-
return new Assertion(val, message);
|
|
2770
|
-
}
|
|
2771
|
-
__name(expect, "expect");
|
|
2772
|
-
expect.fail = function(actual, expected, message, operator) {
|
|
2773
|
-
if (arguments.length < 2) {
|
|
2774
|
-
message = actual;
|
|
2775
|
-
actual = undefined;
|
|
2776
|
-
}
|
|
2777
|
-
message = message || "expect.fail()";
|
|
2778
|
-
throw new AssertionError(message, {
|
|
2779
|
-
actual,
|
|
2780
|
-
expected,
|
|
2781
|
-
operator
|
|
2782
|
-
}, expect.fail);
|
|
2783
|
-
};
|
|
2784
|
-
var should_exports = {};
|
|
2785
|
-
__export2(should_exports, {
|
|
2786
|
-
Should: () => Should,
|
|
2787
|
-
should: () => should
|
|
2788
|
-
});
|
|
2789
|
-
function loadShould() {
|
|
2790
|
-
function shouldGetter() {
|
|
2791
|
-
if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) {
|
|
2792
|
-
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
2793
|
-
}
|
|
2794
|
-
return new Assertion(this, null, shouldGetter);
|
|
2795
|
-
}
|
|
2796
|
-
__name(shouldGetter, "shouldGetter");
|
|
2797
|
-
function shouldSetter(value) {
|
|
2798
|
-
Object.defineProperty(this, "should", {
|
|
2799
|
-
value,
|
|
2800
|
-
enumerable: true,
|
|
2801
|
-
configurable: true,
|
|
2802
|
-
writable: true
|
|
2803
|
-
});
|
|
2804
|
-
}
|
|
2805
|
-
__name(shouldSetter, "shouldSetter");
|
|
2806
|
-
Object.defineProperty(Object.prototype, "should", {
|
|
2807
|
-
set: shouldSetter,
|
|
2808
|
-
get: shouldGetter,
|
|
2809
|
-
configurable: true
|
|
2810
|
-
});
|
|
2811
|
-
let should2 = {};
|
|
2812
|
-
should2.fail = function(actual, expected, message, operator) {
|
|
2813
|
-
if (arguments.length < 2) {
|
|
2814
|
-
message = actual;
|
|
2815
|
-
actual = undefined;
|
|
2816
|
-
}
|
|
2817
|
-
message = message || "should.fail()";
|
|
2818
|
-
throw new AssertionError(message, {
|
|
2819
|
-
actual,
|
|
2820
|
-
expected,
|
|
2821
|
-
operator
|
|
2822
|
-
}, should2.fail);
|
|
2823
|
-
};
|
|
2824
|
-
should2.equal = function(actual, expected, message) {
|
|
2825
|
-
new Assertion(actual, message).to.equal(expected);
|
|
2826
|
-
};
|
|
2827
|
-
should2.Throw = function(fn, errt, errs, msg) {
|
|
2828
|
-
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
2829
|
-
};
|
|
2830
|
-
should2.exist = function(val, msg) {
|
|
2831
|
-
new Assertion(val, msg).to.exist;
|
|
2832
|
-
};
|
|
2833
|
-
should2.not = {};
|
|
2834
|
-
should2.not.equal = function(actual, expected, msg) {
|
|
2835
|
-
new Assertion(actual, msg).to.not.equal(expected);
|
|
2836
|
-
};
|
|
2837
|
-
should2.not.Throw = function(fn, errt, errs, msg) {
|
|
2838
|
-
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
2839
|
-
};
|
|
2840
|
-
should2.not.exist = function(val, msg) {
|
|
2841
|
-
new Assertion(val, msg).to.not.exist;
|
|
2842
|
-
};
|
|
2843
|
-
should2["throw"] = should2["Throw"];
|
|
2844
|
-
should2.not["throw"] = should2.not["Throw"];
|
|
2845
|
-
return should2;
|
|
2846
|
-
}
|
|
2847
|
-
__name(loadShould, "loadShould");
|
|
2848
|
-
var should = loadShould;
|
|
2849
|
-
var Should = loadShould;
|
|
2850
|
-
function assert(express, errmsg) {
|
|
2851
|
-
let test2 = new Assertion(null, null, assert, true);
|
|
2852
|
-
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
2853
|
-
}
|
|
2854
|
-
__name(assert, "assert");
|
|
2855
|
-
assert.fail = function(actual, expected, message, operator) {
|
|
2856
|
-
if (arguments.length < 2) {
|
|
2857
|
-
message = actual;
|
|
2858
|
-
actual = undefined;
|
|
2859
|
-
}
|
|
2860
|
-
message = message || "assert.fail()";
|
|
2861
|
-
throw new AssertionError(message, {
|
|
2862
|
-
actual,
|
|
2863
|
-
expected,
|
|
2864
|
-
operator
|
|
2865
|
-
}, assert.fail);
|
|
2866
|
-
};
|
|
2867
|
-
assert.isOk = function(val, msg) {
|
|
2868
|
-
new Assertion(val, msg, assert.isOk, true).is.ok;
|
|
2869
|
-
};
|
|
2870
|
-
assert.isNotOk = function(val, msg) {
|
|
2871
|
-
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
2872
|
-
};
|
|
2873
|
-
assert.equal = function(act, exp, msg) {
|
|
2874
|
-
let test2 = new Assertion(act, msg, assert.equal, true);
|
|
2875
|
-
test2.assert(exp == flag(test2, "object"), "expected #{this} to equal #{exp}", "expected #{this} to not equal #{act}", exp, act, true);
|
|
2876
|
-
};
|
|
2877
|
-
assert.notEqual = function(act, exp, msg) {
|
|
2878
|
-
let test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
2879
|
-
test2.assert(exp != flag(test2, "object"), "expected #{this} to not equal #{exp}", "expected #{this} to equal #{act}", exp, act, true);
|
|
2880
|
-
};
|
|
2881
|
-
assert.strictEqual = function(act, exp, msg) {
|
|
2882
|
-
new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
|
|
2883
|
-
};
|
|
2884
|
-
assert.notStrictEqual = function(act, exp, msg) {
|
|
2885
|
-
new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
|
|
2886
|
-
};
|
|
2887
|
-
assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
|
|
2888
|
-
new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
|
|
2889
|
-
};
|
|
2890
|
-
assert.notDeepEqual = function(act, exp, msg) {
|
|
2891
|
-
new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
|
|
2892
|
-
};
|
|
2893
|
-
assert.isAbove = function(val, abv, msg) {
|
|
2894
|
-
new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
|
|
2895
|
-
};
|
|
2896
|
-
assert.isAtLeast = function(val, atlst, msg) {
|
|
2897
|
-
new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
|
|
2898
|
-
};
|
|
2899
|
-
assert.isBelow = function(val, blw, msg) {
|
|
2900
|
-
new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
|
|
2901
|
-
};
|
|
2902
|
-
assert.isAtMost = function(val, atmst, msg) {
|
|
2903
|
-
new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
|
|
2904
|
-
};
|
|
2905
|
-
assert.isTrue = function(val, msg) {
|
|
2906
|
-
new Assertion(val, msg, assert.isTrue, true).is["true"];
|
|
2907
|
-
};
|
|
2908
|
-
assert.isNotTrue = function(val, msg) {
|
|
2909
|
-
new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
|
|
2910
|
-
};
|
|
2911
|
-
assert.isFalse = function(val, msg) {
|
|
2912
|
-
new Assertion(val, msg, assert.isFalse, true).is["false"];
|
|
2913
|
-
};
|
|
2914
|
-
assert.isNotFalse = function(val, msg) {
|
|
2915
|
-
new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
|
|
2916
|
-
};
|
|
2917
|
-
assert.isNull = function(val, msg) {
|
|
2918
|
-
new Assertion(val, msg, assert.isNull, true).to.equal(null);
|
|
2919
|
-
};
|
|
2920
|
-
assert.isNotNull = function(val, msg) {
|
|
2921
|
-
new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
|
|
2922
|
-
};
|
|
2923
|
-
assert.isNaN = function(val, msg) {
|
|
2924
|
-
new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
|
|
2925
|
-
};
|
|
2926
|
-
assert.isNotNaN = function(value, message) {
|
|
2927
|
-
new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
|
|
2928
|
-
};
|
|
2929
|
-
assert.exists = function(val, msg) {
|
|
2930
|
-
new Assertion(val, msg, assert.exists, true).to.exist;
|
|
2931
|
-
};
|
|
2932
|
-
assert.notExists = function(val, msg) {
|
|
2933
|
-
new Assertion(val, msg, assert.notExists, true).to.not.exist;
|
|
2934
|
-
};
|
|
2935
|
-
assert.isUndefined = function(val, msg) {
|
|
2936
|
-
new Assertion(val, msg, assert.isUndefined, true).to.equal(undefined);
|
|
2937
|
-
};
|
|
2938
|
-
assert.isDefined = function(val, msg) {
|
|
2939
|
-
new Assertion(val, msg, assert.isDefined, true).to.not.equal(undefined);
|
|
2940
|
-
};
|
|
2941
|
-
assert.isCallable = function(value, message) {
|
|
2942
|
-
new Assertion(value, message, assert.isCallable, true).is.callable;
|
|
2943
|
-
};
|
|
2944
|
-
assert.isNotCallable = function(value, message) {
|
|
2945
|
-
new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
|
|
2946
|
-
};
|
|
2947
|
-
assert.isObject = function(val, msg) {
|
|
2948
|
-
new Assertion(val, msg, assert.isObject, true).to.be.a("object");
|
|
2949
|
-
};
|
|
2950
|
-
assert.isNotObject = function(val, msg) {
|
|
2951
|
-
new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
|
|
2952
|
-
};
|
|
2953
|
-
assert.isArray = function(val, msg) {
|
|
2954
|
-
new Assertion(val, msg, assert.isArray, true).to.be.an("array");
|
|
2955
|
-
};
|
|
2956
|
-
assert.isNotArray = function(val, msg) {
|
|
2957
|
-
new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
|
|
2958
|
-
};
|
|
2959
|
-
assert.isString = function(val, msg) {
|
|
2960
|
-
new Assertion(val, msg, assert.isString, true).to.be.a("string");
|
|
2961
|
-
};
|
|
2962
|
-
assert.isNotString = function(val, msg) {
|
|
2963
|
-
new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
|
|
2964
|
-
};
|
|
2965
|
-
assert.isNumber = function(val, msg) {
|
|
2966
|
-
new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
|
|
2967
|
-
};
|
|
2968
|
-
assert.isNotNumber = function(val, msg) {
|
|
2969
|
-
new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
|
|
2970
|
-
};
|
|
2971
|
-
assert.isNumeric = function(val, msg) {
|
|
2972
|
-
new Assertion(val, msg, assert.isNumeric, true).is.numeric;
|
|
2973
|
-
};
|
|
2974
|
-
assert.isNotNumeric = function(val, msg) {
|
|
2975
|
-
new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
|
|
2976
|
-
};
|
|
2977
|
-
assert.isFinite = function(val, msg) {
|
|
2978
|
-
new Assertion(val, msg, assert.isFinite, true).to.be.finite;
|
|
2979
|
-
};
|
|
2980
|
-
assert.isBoolean = function(val, msg) {
|
|
2981
|
-
new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
|
|
2982
|
-
};
|
|
2983
|
-
assert.isNotBoolean = function(val, msg) {
|
|
2984
|
-
new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
|
|
2985
|
-
};
|
|
2986
|
-
assert.typeOf = function(val, type3, msg) {
|
|
2987
|
-
new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
|
|
2988
|
-
};
|
|
2989
|
-
assert.notTypeOf = function(value, type3, message) {
|
|
2990
|
-
new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
|
|
2991
|
-
};
|
|
2992
|
-
assert.instanceOf = function(val, type3, msg) {
|
|
2993
|
-
new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
|
|
2994
|
-
};
|
|
2995
|
-
assert.notInstanceOf = function(val, type3, msg) {
|
|
2996
|
-
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(type3);
|
|
2997
|
-
};
|
|
2998
|
-
assert.include = function(exp, inc, msg) {
|
|
2999
|
-
new Assertion(exp, msg, assert.include, true).include(inc);
|
|
3000
|
-
};
|
|
3001
|
-
assert.notInclude = function(exp, inc, msg) {
|
|
3002
|
-
new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
|
|
3003
|
-
};
|
|
3004
|
-
assert.deepInclude = function(exp, inc, msg) {
|
|
3005
|
-
new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
|
|
3006
|
-
};
|
|
3007
|
-
assert.notDeepInclude = function(exp, inc, msg) {
|
|
3008
|
-
new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
|
|
3009
|
-
};
|
|
3010
|
-
assert.nestedInclude = function(exp, inc, msg) {
|
|
3011
|
-
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
3012
|
-
};
|
|
3013
|
-
assert.notNestedInclude = function(exp, inc, msg) {
|
|
3014
|
-
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(inc);
|
|
3015
|
-
};
|
|
3016
|
-
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
3017
|
-
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(inc);
|
|
3018
|
-
};
|
|
3019
|
-
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
3020
|
-
new Assertion(exp, msg, assert.notDeepNestedInclude, true).not.deep.nested.include(inc);
|
|
3021
|
-
};
|
|
3022
|
-
assert.ownInclude = function(exp, inc, msg) {
|
|
3023
|
-
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
3024
|
-
};
|
|
3025
|
-
assert.notOwnInclude = function(exp, inc, msg) {
|
|
3026
|
-
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
|
|
3027
|
-
};
|
|
3028
|
-
assert.deepOwnInclude = function(exp, inc, msg) {
|
|
3029
|
-
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
3030
|
-
};
|
|
3031
|
-
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
3032
|
-
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(inc);
|
|
3033
|
-
};
|
|
3034
|
-
assert.match = function(exp, re, msg) {
|
|
3035
|
-
new Assertion(exp, msg, assert.match, true).to.match(re);
|
|
3036
|
-
};
|
|
3037
|
-
assert.notMatch = function(exp, re, msg) {
|
|
3038
|
-
new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
|
|
3039
|
-
};
|
|
3040
|
-
assert.property = function(obj, prop, msg) {
|
|
3041
|
-
new Assertion(obj, msg, assert.property, true).to.have.property(prop);
|
|
3042
|
-
};
|
|
3043
|
-
assert.notProperty = function(obj, prop, msg) {
|
|
3044
|
-
new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
|
|
3045
|
-
};
|
|
3046
|
-
assert.propertyVal = function(obj, prop, val, msg) {
|
|
3047
|
-
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
3048
|
-
};
|
|
3049
|
-
assert.notPropertyVal = function(obj, prop, val, msg) {
|
|
3050
|
-
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(prop, val);
|
|
3051
|
-
};
|
|
3052
|
-
assert.deepPropertyVal = function(obj, prop, val, msg) {
|
|
3053
|
-
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(prop, val);
|
|
3054
|
-
};
|
|
3055
|
-
assert.notDeepPropertyVal = function(obj, prop, val, msg) {
|
|
3056
|
-
new Assertion(obj, msg, assert.notDeepPropertyVal, true).to.not.have.deep.property(prop, val);
|
|
3057
|
-
};
|
|
3058
|
-
assert.ownProperty = function(obj, prop, msg) {
|
|
3059
|
-
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
3060
|
-
};
|
|
3061
|
-
assert.notOwnProperty = function(obj, prop, msg) {
|
|
3062
|
-
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(prop);
|
|
3063
|
-
};
|
|
3064
|
-
assert.ownPropertyVal = function(obj, prop, value, msg) {
|
|
3065
|
-
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(prop, value);
|
|
3066
|
-
};
|
|
3067
|
-
assert.notOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3068
|
-
new Assertion(obj, msg, assert.notOwnPropertyVal, true).to.not.have.own.property(prop, value);
|
|
3069
|
-
};
|
|
3070
|
-
assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3071
|
-
new Assertion(obj, msg, assert.deepOwnPropertyVal, true).to.have.deep.own.property(prop, value);
|
|
3072
|
-
};
|
|
3073
|
-
assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3074
|
-
new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true).to.not.have.deep.own.property(prop, value);
|
|
3075
|
-
};
|
|
3076
|
-
assert.nestedProperty = function(obj, prop, msg) {
|
|
3077
|
-
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(prop);
|
|
3078
|
-
};
|
|
3079
|
-
assert.notNestedProperty = function(obj, prop, msg) {
|
|
3080
|
-
new Assertion(obj, msg, assert.notNestedProperty, true).to.not.have.nested.property(prop);
|
|
3081
|
-
};
|
|
3082
|
-
assert.nestedPropertyVal = function(obj, prop, val, msg) {
|
|
3083
|
-
new Assertion(obj, msg, assert.nestedPropertyVal, true).to.have.nested.property(prop, val);
|
|
3084
|
-
};
|
|
3085
|
-
assert.notNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3086
|
-
new Assertion(obj, msg, assert.notNestedPropertyVal, true).to.not.have.nested.property(prop, val);
|
|
3087
|
-
};
|
|
3088
|
-
assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3089
|
-
new Assertion(obj, msg, assert.deepNestedPropertyVal, true).to.have.deep.nested.property(prop, val);
|
|
3090
|
-
};
|
|
3091
|
-
assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3092
|
-
new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true).to.not.have.deep.nested.property(prop, val);
|
|
3093
|
-
};
|
|
3094
|
-
assert.lengthOf = function(exp, len, msg) {
|
|
3095
|
-
new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
|
|
3096
|
-
};
|
|
3097
|
-
assert.hasAnyKeys = function(obj, keys, msg) {
|
|
3098
|
-
new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
|
|
3099
|
-
};
|
|
3100
|
-
assert.hasAllKeys = function(obj, keys, msg) {
|
|
3101
|
-
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
3102
|
-
};
|
|
3103
|
-
assert.containsAllKeys = function(obj, keys, msg) {
|
|
3104
|
-
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(keys);
|
|
3105
|
-
};
|
|
3106
|
-
assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
|
|
3107
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(keys);
|
|
3108
|
-
};
|
|
3109
|
-
assert.doesNotHaveAllKeys = function(obj, keys, msg) {
|
|
3110
|
-
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(keys);
|
|
3111
|
-
};
|
|
3112
|
-
assert.hasAnyDeepKeys = function(obj, keys, msg) {
|
|
3113
|
-
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(keys);
|
|
3114
|
-
};
|
|
3115
|
-
assert.hasAllDeepKeys = function(obj, keys, msg) {
|
|
3116
|
-
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(keys);
|
|
3117
|
-
};
|
|
3118
|
-
assert.containsAllDeepKeys = function(obj, keys, msg) {
|
|
3119
|
-
new Assertion(obj, msg, assert.containsAllDeepKeys, true).to.contain.all.deep.keys(keys);
|
|
3120
|
-
};
|
|
3121
|
-
assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
|
|
3122
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true).to.not.have.any.deep.keys(keys);
|
|
3123
|
-
};
|
|
3124
|
-
assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
|
|
3125
|
-
new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true).to.not.have.all.deep.keys(keys);
|
|
3126
|
-
};
|
|
3127
|
-
assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
3128
|
-
if (typeof errorLike === "string" || errorLike instanceof RegExp) {
|
|
3129
|
-
errMsgMatcher = errorLike;
|
|
3130
|
-
errorLike = null;
|
|
3131
|
-
}
|
|
3132
|
-
let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher);
|
|
3133
|
-
return flag(assertErr, "object");
|
|
3134
|
-
};
|
|
3135
|
-
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
3136
|
-
if (typeof errorLike === "string" || errorLike instanceof RegExp) {
|
|
3137
|
-
errMsgMatcher = errorLike;
|
|
3138
|
-
errorLike = null;
|
|
3139
|
-
}
|
|
3140
|
-
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
|
|
3141
|
-
};
|
|
3142
|
-
assert.operator = function(val, operator, val2, msg) {
|
|
3143
|
-
let ok;
|
|
3144
|
-
switch (operator) {
|
|
3145
|
-
case "==":
|
|
3146
|
-
ok = val == val2;
|
|
3147
|
-
break;
|
|
3148
|
-
case "===":
|
|
3149
|
-
ok = val === val2;
|
|
3150
|
-
break;
|
|
3151
|
-
case ">":
|
|
3152
|
-
ok = val > val2;
|
|
3153
|
-
break;
|
|
3154
|
-
case ">=":
|
|
3155
|
-
ok = val >= val2;
|
|
3156
|
-
break;
|
|
3157
|
-
case "<":
|
|
3158
|
-
ok = val < val2;
|
|
3159
|
-
break;
|
|
3160
|
-
case "<=":
|
|
3161
|
-
ok = val <= val2;
|
|
3162
|
-
break;
|
|
3163
|
-
case "!=":
|
|
3164
|
-
ok = val != val2;
|
|
3165
|
-
break;
|
|
3166
|
-
case "!==":
|
|
3167
|
-
ok = val !== val2;
|
|
3168
|
-
break;
|
|
3169
|
-
default:
|
|
3170
|
-
msg = msg ? msg + ": " : msg;
|
|
3171
|
-
throw new AssertionError(msg + 'Invalid operator "' + operator + '"', undefined, assert.operator);
|
|
3172
|
-
}
|
|
3173
|
-
let test2 = new Assertion(ok, msg, assert.operator, true);
|
|
3174
|
-
test2.assert(flag(test2, "object") === true, "expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2), "expected " + inspect2(val) + " to not be " + operator + " " + inspect2(val2));
|
|
3175
|
-
};
|
|
3176
|
-
assert.closeTo = function(act, exp, delta, msg) {
|
|
3177
|
-
new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
|
|
3178
|
-
};
|
|
3179
|
-
assert.approximately = function(act, exp, delta, msg) {
|
|
3180
|
-
new Assertion(act, msg, assert.approximately, true).to.be.approximately(exp, delta);
|
|
3181
|
-
};
|
|
3182
|
-
assert.sameMembers = function(set1, set2, msg) {
|
|
3183
|
-
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
3184
|
-
};
|
|
3185
|
-
assert.notSameMembers = function(set1, set2, msg) {
|
|
3186
|
-
new Assertion(set1, msg, assert.notSameMembers, true).to.not.have.same.members(set2);
|
|
3187
|
-
};
|
|
3188
|
-
assert.sameDeepMembers = function(set1, set2, msg) {
|
|
3189
|
-
new Assertion(set1, msg, assert.sameDeepMembers, true).to.have.same.deep.members(set2);
|
|
3190
|
-
};
|
|
3191
|
-
assert.notSameDeepMembers = function(set1, set2, msg) {
|
|
3192
|
-
new Assertion(set1, msg, assert.notSameDeepMembers, true).to.not.have.same.deep.members(set2);
|
|
3193
|
-
};
|
|
3194
|
-
assert.sameOrderedMembers = function(set1, set2, msg) {
|
|
3195
|
-
new Assertion(set1, msg, assert.sameOrderedMembers, true).to.have.same.ordered.members(set2);
|
|
3196
|
-
};
|
|
3197
|
-
assert.notSameOrderedMembers = function(set1, set2, msg) {
|
|
3198
|
-
new Assertion(set1, msg, assert.notSameOrderedMembers, true).to.not.have.same.ordered.members(set2);
|
|
3199
|
-
};
|
|
3200
|
-
assert.sameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3201
|
-
new Assertion(set1, msg, assert.sameDeepOrderedMembers, true).to.have.same.deep.ordered.members(set2);
|
|
3202
|
-
};
|
|
3203
|
-
assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3204
|
-
new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true).to.not.have.same.deep.ordered.members(set2);
|
|
3205
|
-
};
|
|
3206
|
-
assert.includeMembers = function(superset, subset, msg) {
|
|
3207
|
-
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(subset);
|
|
3208
|
-
};
|
|
3209
|
-
assert.notIncludeMembers = function(superset, subset, msg) {
|
|
3210
|
-
new Assertion(superset, msg, assert.notIncludeMembers, true).to.not.include.members(subset);
|
|
3211
|
-
};
|
|
3212
|
-
assert.includeDeepMembers = function(superset, subset, msg) {
|
|
3213
|
-
new Assertion(superset, msg, assert.includeDeepMembers, true).to.include.deep.members(subset);
|
|
3214
|
-
};
|
|
3215
|
-
assert.notIncludeDeepMembers = function(superset, subset, msg) {
|
|
3216
|
-
new Assertion(superset, msg, assert.notIncludeDeepMembers, true).to.not.include.deep.members(subset);
|
|
3217
|
-
};
|
|
3218
|
-
assert.includeOrderedMembers = function(superset, subset, msg) {
|
|
3219
|
-
new Assertion(superset, msg, assert.includeOrderedMembers, true).to.include.ordered.members(subset);
|
|
3220
|
-
};
|
|
3221
|
-
assert.notIncludeOrderedMembers = function(superset, subset, msg) {
|
|
3222
|
-
new Assertion(superset, msg, assert.notIncludeOrderedMembers, true).to.not.include.ordered.members(subset);
|
|
3223
|
-
};
|
|
3224
|
-
assert.includeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3225
|
-
new Assertion(superset, msg, assert.includeDeepOrderedMembers, true).to.include.deep.ordered.members(subset);
|
|
3226
|
-
};
|
|
3227
|
-
assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3228
|
-
new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true).to.not.include.deep.ordered.members(subset);
|
|
3229
|
-
};
|
|
3230
|
-
assert.oneOf = function(inList, list, msg) {
|
|
3231
|
-
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
3232
|
-
};
|
|
3233
|
-
assert.isIterable = function(obj, msg) {
|
|
3234
|
-
if (obj == undefined || !obj[Symbol.iterator]) {
|
|
3235
|
-
msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
|
|
3236
|
-
throw new AssertionError(msg, undefined, assert.isIterable);
|
|
3237
|
-
}
|
|
3238
|
-
};
|
|
3239
|
-
assert.changes = function(fn, obj, prop, msg) {
|
|
3240
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3241
|
-
msg = prop;
|
|
3242
|
-
prop = null;
|
|
3243
|
-
}
|
|
3244
|
-
new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
|
|
3245
|
-
};
|
|
3246
|
-
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
3247
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3248
|
-
let tmpMsg = delta;
|
|
3249
|
-
delta = prop;
|
|
3250
|
-
msg = tmpMsg;
|
|
3251
|
-
} else if (arguments.length === 3) {
|
|
3252
|
-
delta = prop;
|
|
3253
|
-
prop = null;
|
|
3254
|
-
}
|
|
3255
|
-
new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
|
|
3256
|
-
};
|
|
3257
|
-
assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
3258
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3259
|
-
msg = prop;
|
|
3260
|
-
prop = null;
|
|
3261
|
-
}
|
|
3262
|
-
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(obj, prop);
|
|
3263
|
-
};
|
|
3264
|
-
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3265
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3266
|
-
let tmpMsg = delta;
|
|
3267
|
-
delta = prop;
|
|
3268
|
-
msg = tmpMsg;
|
|
3269
|
-
} else if (arguments.length === 3) {
|
|
3270
|
-
delta = prop;
|
|
3271
|
-
prop = null;
|
|
3272
|
-
}
|
|
3273
|
-
new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
|
|
3274
|
-
};
|
|
3275
|
-
assert.increases = function(fn, obj, prop, msg) {
|
|
3276
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3277
|
-
msg = prop;
|
|
3278
|
-
prop = null;
|
|
3279
|
-
}
|
|
3280
|
-
return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
|
|
3281
|
-
};
|
|
3282
|
-
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
3283
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3284
|
-
let tmpMsg = delta;
|
|
3285
|
-
delta = prop;
|
|
3286
|
-
msg = tmpMsg;
|
|
3287
|
-
} else if (arguments.length === 3) {
|
|
3288
|
-
delta = prop;
|
|
3289
|
-
prop = null;
|
|
3290
|
-
}
|
|
3291
|
-
new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
|
|
3292
|
-
};
|
|
3293
|
-
assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
3294
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3295
|
-
msg = prop;
|
|
3296
|
-
prop = null;
|
|
3297
|
-
}
|
|
3298
|
-
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(obj, prop);
|
|
3299
|
-
};
|
|
3300
|
-
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3301
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3302
|
-
let tmpMsg = delta;
|
|
3303
|
-
delta = prop;
|
|
3304
|
-
msg = tmpMsg;
|
|
3305
|
-
} else if (arguments.length === 3) {
|
|
3306
|
-
delta = prop;
|
|
3307
|
-
prop = null;
|
|
3308
|
-
}
|
|
3309
|
-
new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
|
|
3310
|
-
};
|
|
3311
|
-
assert.decreases = function(fn, obj, prop, msg) {
|
|
3312
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3313
|
-
msg = prop;
|
|
3314
|
-
prop = null;
|
|
3315
|
-
}
|
|
3316
|
-
return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
|
|
3317
|
-
};
|
|
3318
|
-
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
3319
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3320
|
-
let tmpMsg = delta;
|
|
3321
|
-
delta = prop;
|
|
3322
|
-
msg = tmpMsg;
|
|
3323
|
-
} else if (arguments.length === 3) {
|
|
3324
|
-
delta = prop;
|
|
3325
|
-
prop = null;
|
|
3326
|
-
}
|
|
3327
|
-
new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
|
|
3328
|
-
};
|
|
3329
|
-
assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
3330
|
-
if (arguments.length === 3 && typeof obj === "function") {
|
|
3331
|
-
msg = prop;
|
|
3332
|
-
prop = null;
|
|
3333
|
-
}
|
|
3334
|
-
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(obj, prop);
|
|
3335
|
-
};
|
|
3336
|
-
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
3337
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3338
|
-
let tmpMsg = delta;
|
|
3339
|
-
delta = prop;
|
|
3340
|
-
msg = tmpMsg;
|
|
3341
|
-
} else if (arguments.length === 3) {
|
|
3342
|
-
delta = prop;
|
|
3343
|
-
prop = null;
|
|
3344
|
-
}
|
|
3345
|
-
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
|
|
3346
|
-
};
|
|
3347
|
-
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3348
|
-
if (arguments.length === 4 && typeof obj === "function") {
|
|
3349
|
-
let tmpMsg = delta;
|
|
3350
|
-
delta = prop;
|
|
3351
|
-
msg = tmpMsg;
|
|
3352
|
-
} else if (arguments.length === 3) {
|
|
3353
|
-
delta = prop;
|
|
3354
|
-
prop = null;
|
|
3355
|
-
}
|
|
3356
|
-
new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
|
|
3357
|
-
};
|
|
3358
|
-
assert.ifError = function(val) {
|
|
3359
|
-
if (val) {
|
|
3360
|
-
throw val;
|
|
3361
|
-
}
|
|
3362
|
-
};
|
|
3363
|
-
assert.isExtensible = function(obj, msg) {
|
|
3364
|
-
new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
|
|
3365
|
-
};
|
|
3366
|
-
assert.isNotExtensible = function(obj, msg) {
|
|
3367
|
-
new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
|
|
3368
|
-
};
|
|
3369
|
-
assert.isSealed = function(obj, msg) {
|
|
3370
|
-
new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
|
|
3371
|
-
};
|
|
3372
|
-
assert.isNotSealed = function(obj, msg) {
|
|
3373
|
-
new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
|
|
3374
|
-
};
|
|
3375
|
-
assert.isFrozen = function(obj, msg) {
|
|
3376
|
-
new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
|
|
3377
|
-
};
|
|
3378
|
-
assert.isNotFrozen = function(obj, msg) {
|
|
3379
|
-
new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
|
|
3380
|
-
};
|
|
3381
|
-
assert.isEmpty = function(val, msg) {
|
|
3382
|
-
new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
|
|
3383
|
-
};
|
|
3384
|
-
assert.isNotEmpty = function(val, msg) {
|
|
3385
|
-
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
3386
|
-
};
|
|
3387
|
-
assert.containsSubset = function(val, exp, msg) {
|
|
3388
|
-
new Assertion(val, msg).to.containSubset(exp);
|
|
3389
|
-
};
|
|
3390
|
-
assert.doesNotContainSubset = function(val, exp, msg) {
|
|
3391
|
-
new Assertion(val, msg).to.not.containSubset(exp);
|
|
3392
|
-
};
|
|
3393
|
-
var aliases = [
|
|
3394
|
-
["isOk", "ok"],
|
|
3395
|
-
["isNotOk", "notOk"],
|
|
3396
|
-
["throws", "throw"],
|
|
3397
|
-
["throws", "Throw"],
|
|
3398
|
-
["isExtensible", "extensible"],
|
|
3399
|
-
["isNotExtensible", "notExtensible"],
|
|
3400
|
-
["isSealed", "sealed"],
|
|
3401
|
-
["isNotSealed", "notSealed"],
|
|
3402
|
-
["isFrozen", "frozen"],
|
|
3403
|
-
["isNotFrozen", "notFrozen"],
|
|
3404
|
-
["isEmpty", "empty"],
|
|
3405
|
-
["isNotEmpty", "notEmpty"],
|
|
3406
|
-
["isCallable", "isFunction"],
|
|
3407
|
-
["isNotCallable", "isNotFunction"],
|
|
3408
|
-
["containsSubset", "containSubset"]
|
|
3409
|
-
];
|
|
3410
|
-
for (const [name, as] of aliases) {
|
|
3411
|
-
assert[as] = assert[name];
|
|
3412
|
-
}
|
|
3413
|
-
var used = [];
|
|
3414
|
-
function use(fn) {
|
|
3415
|
-
const exports = {
|
|
3416
|
-
use,
|
|
3417
|
-
AssertionError,
|
|
3418
|
-
util: utils_exports,
|
|
3419
|
-
config,
|
|
3420
|
-
expect,
|
|
3421
|
-
assert,
|
|
3422
|
-
Assertion,
|
|
3423
|
-
...should_exports
|
|
3424
|
-
};
|
|
3425
|
-
if (!~used.indexOf(fn)) {
|
|
3426
|
-
fn(exports, utils_exports);
|
|
3427
|
-
used.push(fn);
|
|
3428
|
-
}
|
|
3429
|
-
return exports;
|
|
3430
|
-
}
|
|
3431
|
-
__name(use, "use");
|
|
125
|
+
import { expect } from "chai";
|
|
3432
126
|
|
|
3433
127
|
// src/anode.js
|
|
3434
128
|
var exports_anode = {};
|
|
@@ -3800,8 +494,8 @@ class Path {
|
|
|
3800
494
|
return [new Path(pathSteps.reverse()), handlers];
|
|
3801
495
|
}
|
|
3802
496
|
static fromEvent(e, rNode, maxDepth, comps, stopOnNoEvent = true) {
|
|
3803
|
-
const { type
|
|
3804
|
-
return Path.fromNodeAndEventName(target,
|
|
497
|
+
const { type, target } = e;
|
|
498
|
+
return Path.fromNodeAndEventName(target, type, rNode, maxDepth, comps, stopOnNoEvent);
|
|
3805
499
|
}
|
|
3806
500
|
}
|
|
3807
501
|
function metaChain(n) {
|
|
@@ -4242,8 +936,8 @@ class HandlerNameVal extends NameVal {
|
|
|
4242
936
|
return stack.getHandlerFor(this.name, this.namespace) ?? mk404Handler(this.namespace, this.name);
|
|
4243
937
|
}
|
|
4244
938
|
}
|
|
4245
|
-
var mk404Handler = (
|
|
4246
|
-
console.warn("handler not found", { type
|
|
939
|
+
var mk404Handler = (type, name) => function(...args) {
|
|
940
|
+
console.warn("handler not found", { type, name, args }, this);
|
|
4247
941
|
return this;
|
|
4248
942
|
};
|
|
4249
943
|
|
|
@@ -4860,13 +1554,13 @@ function diffProps(a, b) {
|
|
|
4860
1554
|
function morphNode(domNode, source, target, opts) {
|
|
4861
1555
|
if (source === target || source.isEqualTo(target))
|
|
4862
1556
|
return domNode;
|
|
4863
|
-
const
|
|
4864
|
-
if (
|
|
4865
|
-
if (
|
|
1557
|
+
const type = source.nodeType;
|
|
1558
|
+
if (type === target.nodeType) {
|
|
1559
|
+
if (type === 3 || type === 8) {
|
|
4866
1560
|
domNode.data = target.text;
|
|
4867
1561
|
return domNode;
|
|
4868
1562
|
}
|
|
4869
|
-
if (
|
|
1563
|
+
if (type === 1 && source.isSameKind(target)) {
|
|
4870
1564
|
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
4871
1565
|
let pendingValue;
|
|
4872
1566
|
let pendingChecked;
|
|
@@ -4901,7 +1595,7 @@ function morphNode(domNode, source, target, opts) {
|
|
|
4901
1595
|
setProp(domNode, "checked", pendingChecked, false);
|
|
4902
1596
|
return domNode;
|
|
4903
1597
|
}
|
|
4904
|
-
if (
|
|
1598
|
+
if (type === 11) {
|
|
4905
1599
|
morphChildren(domNode, source.childs, target.childs, opts);
|
|
4906
1600
|
return domNode;
|
|
4907
1601
|
}
|
|
@@ -4944,18 +1638,18 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
|
4944
1638
|
if (key != null)
|
|
4945
1639
|
oldKeyMap[key] = i;
|
|
4946
1640
|
}
|
|
4947
|
-
const
|
|
1641
|
+
const used = new Uint8Array(oldChilds.length);
|
|
4948
1642
|
let unkeyedCursor = 0;
|
|
4949
1643
|
for (let j = 0;j < newChilds.length; j++) {
|
|
4950
1644
|
const newChild = newChilds[j];
|
|
4951
1645
|
const newKey = getKey(newChild);
|
|
4952
1646
|
let oldIdx = -1;
|
|
4953
1647
|
if (newKey != null) {
|
|
4954
|
-
if (newKey in oldKeyMap && !
|
|
1648
|
+
if (newKey in oldKeyMap && !used[oldKeyMap[newKey]])
|
|
4955
1649
|
oldIdx = oldKeyMap[newKey];
|
|
4956
1650
|
} else {
|
|
4957
1651
|
while (unkeyedCursor < oldChilds.length) {
|
|
4958
|
-
if (!
|
|
1652
|
+
if (!used[unkeyedCursor] && getKey(oldChilds[unkeyedCursor]) == null) {
|
|
4959
1653
|
oldIdx = unkeyedCursor++;
|
|
4960
1654
|
break;
|
|
4961
1655
|
}
|
|
@@ -4963,7 +1657,7 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
|
4963
1657
|
}
|
|
4964
1658
|
}
|
|
4965
1659
|
if (oldIdx >= 0) {
|
|
4966
|
-
|
|
1660
|
+
used[oldIdx] = 1;
|
|
4967
1661
|
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
4968
1662
|
const ref = parentDom.childNodes[j] ?? null;
|
|
4969
1663
|
if (newDom !== ref)
|
|
@@ -4974,7 +1668,7 @@ function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
|
4974
1668
|
}
|
|
4975
1669
|
}
|
|
4976
1670
|
for (let i = oldChilds.length - 1;i >= 0; i--)
|
|
4977
|
-
if (!
|
|
1671
|
+
if (!used[i] && domNodes[i].parentNode === parentDom)
|
|
4978
1672
|
parentDom.removeChild(domNodes[i]);
|
|
4979
1673
|
}
|
|
4980
1674
|
function render(vnode, container, options, prev) {
|
|
@@ -5566,9 +2260,9 @@ var WRAPPER_NODES = {
|
|
|
5566
2260
|
};
|
|
5567
2261
|
|
|
5568
2262
|
class ParseContext {
|
|
5569
|
-
constructor(document2, Text, Comment, nodes,
|
|
2263
|
+
constructor(document2, Text, Comment, nodes, events, macroNodes, frame, parent) {
|
|
5570
2264
|
this.nodes = nodes ?? [];
|
|
5571
|
-
this.events =
|
|
2265
|
+
this.events = events ?? [];
|
|
5572
2266
|
this.macroNodes = macroNodes ?? [];
|
|
5573
2267
|
this.parent = parent ?? null;
|
|
5574
2268
|
this.frame = frame ?? {};
|
|
@@ -5582,9 +2276,9 @@ class ParseContext {
|
|
|
5582
2276
|
return this.frame.macroName === name || this.parent?.isInsideMacro(name);
|
|
5583
2277
|
}
|
|
5584
2278
|
enterMacro(macroName, macroVars, macroSlots) {
|
|
5585
|
-
const { document: document2, Text, Comment, nodes, events
|
|
2279
|
+
const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
|
|
5586
2280
|
const frame = { macroName, macroVars, macroSlots };
|
|
5587
|
-
return new ParseContext(document2, Text, Comment, nodes,
|
|
2281
|
+
return new ParseContext(document2, Text, Comment, nodes, events, macroNodes, frame, this);
|
|
5588
2282
|
}
|
|
5589
2283
|
parseHTML(html) {
|
|
5590
2284
|
const t = this.document.createElement("template");
|
|
@@ -5602,9 +2296,9 @@ class ParseContext {
|
|
|
5602
2296
|
}
|
|
5603
2297
|
registerEvents() {
|
|
5604
2298
|
const id = this.events.length;
|
|
5605
|
-
const
|
|
5606
|
-
this.events.push(
|
|
5607
|
-
return
|
|
2299
|
+
const events = new NodeEvents(id);
|
|
2300
|
+
this.events.push(events);
|
|
2301
|
+
return events;
|
|
5608
2302
|
}
|
|
5609
2303
|
newMacroNode(macroName, mAttrs, childs) {
|
|
5610
2304
|
const anySlot = [];
|
|
@@ -5778,9 +2472,9 @@ class ParseCtxClassSetCollector extends ParseContext {
|
|
|
5778
2472
|
}
|
|
5779
2473
|
}
|
|
5780
2474
|
enterMacro(macroName, macroVars, macroSlots) {
|
|
5781
|
-
const { document: document2, Text, Comment, nodes, events
|
|
2475
|
+
const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
|
|
5782
2476
|
const frame = { macroName, macroVars, macroSlots };
|
|
5783
|
-
const v = new ParseCtxClassSetCollector(document2, Text, Comment, nodes,
|
|
2477
|
+
const v = new ParseCtxClassSetCollector(document2, Text, Comment, nodes, events, macroNodes, frame, this);
|
|
5784
2478
|
v.classes = this.classes;
|
|
5785
2479
|
return v;
|
|
5786
2480
|
}
|
|
@@ -7681,8 +4375,8 @@ class LinterCtx {
|
|
|
7681
4375
|
return this.startInBody(name, raw, selfClosing, start, endIndex);
|
|
7682
4376
|
}
|
|
7683
4377
|
if (name === "input") {
|
|
7684
|
-
const
|
|
7685
|
-
if (
|
|
4378
|
+
const type = (this.getAttr("type") ?? "").toLowerCase();
|
|
4379
|
+
if (type === "hidden")
|
|
7686
4380
|
return;
|
|
7687
4381
|
this.report(HTML_TAG_NOT_ALLOWED_IN_PARENT, LEVEL_WARN, start, {
|
|
7688
4382
|
tag: raw,
|
|
@@ -9096,7 +5790,7 @@ function makeCollector({ path = null, components = [] } = {}) {
|
|
|
9096
5790
|
stack.pop();
|
|
9097
5791
|
}
|
|
9098
5792
|
}
|
|
9099
|
-
function
|
|
5793
|
+
function test(title, fn) {
|
|
9100
5794
|
if (typeof title !== "string") {
|
|
9101
5795
|
throw new Error("test(title, fn): title must be a string");
|
|
9102
5796
|
}
|
|
@@ -9114,7 +5808,7 @@ function makeCollector({ path = null, components = [] } = {}) {
|
|
|
9114
5808
|
parent
|
|
9115
5809
|
}));
|
|
9116
5810
|
}
|
|
9117
|
-
return { describe, test
|
|
5811
|
+
return { describe, test, moduleTests };
|
|
9118
5812
|
}
|
|
9119
5813
|
|
|
9120
5814
|
// tools/core/test.js
|
|
@@ -9139,7 +5833,7 @@ async function runTests({
|
|
|
9139
5833
|
getTests,
|
|
9140
5834
|
components = [],
|
|
9141
5835
|
path = null,
|
|
9142
|
-
expect
|
|
5836
|
+
expect,
|
|
9143
5837
|
name = null,
|
|
9144
5838
|
grep = null,
|
|
9145
5839
|
bail = false
|
|
@@ -9150,11 +5844,11 @@ async function runTests({
|
|
|
9150
5844
|
modules: [new ModuleTestReport({ path, suites: [], counts })]
|
|
9151
5845
|
});
|
|
9152
5846
|
}
|
|
9153
|
-
if (typeof
|
|
5847
|
+
if (typeof expect !== "function") {
|
|
9154
5848
|
throw new Error("runTests: expect must be provided (e.g. chai's expect)");
|
|
9155
5849
|
}
|
|
9156
|
-
const { describe, test
|
|
9157
|
-
await getTests({ describe, test
|
|
5850
|
+
const { describe, test, moduleTests } = makeCollector({ path, components });
|
|
5851
|
+
await getTests({ describe, test, expect });
|
|
9158
5852
|
let bailed = false;
|
|
9159
5853
|
async function visit(node) {
|
|
9160
5854
|
if (node instanceof Test) {
|
|
@@ -9527,7 +6221,7 @@ function htmlActionPhrase(action, tag, parent) {
|
|
|
9527
6221
|
var exports_extra = {};
|
|
9528
6222
|
__export(exports_extra, {
|
|
9529
6223
|
tutuca: () => tutuca,
|
|
9530
|
-
test: () =>
|
|
6224
|
+
test: () => test,
|
|
9531
6225
|
macro: () => macro,
|
|
9532
6226
|
isOMap: () => isOrderedMap,
|
|
9533
6227
|
isIMap: () => isMap,
|
|
@@ -9589,10 +6283,10 @@ class Components {
|
|
|
9589
6283
|
return this.getCompFor(v)?.scope.lookupRequest(name) ?? null;
|
|
9590
6284
|
}
|
|
9591
6285
|
compileStyles() {
|
|
9592
|
-
const
|
|
6286
|
+
const styles = [];
|
|
9593
6287
|
for (const comp of this.byId.values())
|
|
9594
|
-
|
|
9595
|
-
return
|
|
6288
|
+
styles.push(comp.compileStyle());
|
|
6289
|
+
return styles.join(`
|
|
9596
6290
|
`);
|
|
9597
6291
|
}
|
|
9598
6292
|
}
|
|
@@ -9609,20 +6303,20 @@ class ComponentStack {
|
|
|
9609
6303
|
return new ComponentStack(this.comps, this);
|
|
9610
6304
|
}
|
|
9611
6305
|
registerComponents(comps, opts) {
|
|
9612
|
-
const { aliases
|
|
6306
|
+
const { aliases = {} } = opts ?? {};
|
|
9613
6307
|
for (let i = 0;i < comps.length; i++) {
|
|
9614
6308
|
const comp = comps[i];
|
|
9615
6309
|
comp.scope = this.enter();
|
|
9616
6310
|
this.comps.registerComponent(comp);
|
|
9617
6311
|
this.byName[comp.name] = comp;
|
|
9618
6312
|
}
|
|
9619
|
-
for (const alias in
|
|
9620
|
-
const comp = this.byName[
|
|
6313
|
+
for (const alias in aliases) {
|
|
6314
|
+
const comp = this.byName[aliases[alias]];
|
|
9621
6315
|
console.assert(this.byName[alias] === undefined, "alias overrides component", alias);
|
|
9622
6316
|
if (comp !== undefined)
|
|
9623
6317
|
this.byName[alias] = comp;
|
|
9624
6318
|
else
|
|
9625
|
-
console.warn("alias", alias, "to inexistent component",
|
|
6319
|
+
console.warn("alias", alias, "to inexistent component", aliases[alias]);
|
|
9626
6320
|
}
|
|
9627
6321
|
}
|
|
9628
6322
|
registerMacros(macros) {
|
|
@@ -9740,15 +6434,15 @@ class Component {
|
|
|
9740
6434
|
}
|
|
9741
6435
|
compileStyle() {
|
|
9742
6436
|
const { id, commonStyle, globalStyle, views } = this;
|
|
9743
|
-
const
|
|
6437
|
+
const styles = commonStyle ? [`[data-cid="${id}"]{${commonStyle}}`] : [];
|
|
9744
6438
|
if (globalStyle !== "")
|
|
9745
|
-
|
|
6439
|
+
styles.push(globalStyle);
|
|
9746
6440
|
for (const name in views) {
|
|
9747
6441
|
const { style } = views[name];
|
|
9748
6442
|
if (style !== "")
|
|
9749
|
-
|
|
6443
|
+
styles.push(`[data-cid="${id}"][data-vid="${name}"]{${style}}`);
|
|
9750
6444
|
}
|
|
9751
|
-
return
|
|
6445
|
+
return styles.join(`
|
|
9752
6446
|
`);
|
|
9753
6447
|
}
|
|
9754
6448
|
}
|
|
@@ -10256,27 +6950,27 @@ class App {
|
|
|
10256
6950
|
return this.transactor.state;
|
|
10257
6951
|
}
|
|
10258
6952
|
handleEvent(e) {
|
|
10259
|
-
const { type
|
|
10260
|
-
if (
|
|
6953
|
+
const { type } = e;
|
|
6954
|
+
if (type[0] === "t" && type.startsWith("touch")) {
|
|
10261
6955
|
this._handleTouchEvent(e);
|
|
10262
6956
|
return;
|
|
10263
6957
|
}
|
|
10264
6958
|
this._dispatchEvent(e);
|
|
10265
6959
|
}
|
|
10266
6960
|
_dispatchEvent(e) {
|
|
10267
|
-
const { type
|
|
10268
|
-
const isDrag =
|
|
6961
|
+
const { type } = e;
|
|
6962
|
+
const isDrag = type === "dragover" || type === "dragstart" || type === "dragend" || type === "drop";
|
|
10269
6963
|
const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
|
|
10270
6964
|
const [path, handlers] = Path.fromEvent(e, root, maxDepth, comps, !isDrag);
|
|
10271
6965
|
if (isDrag)
|
|
10272
|
-
this._handleDragEvent(e,
|
|
6966
|
+
this._handleDragEvent(e, type, path);
|
|
10273
6967
|
if (path !== null && handlers !== null)
|
|
10274
6968
|
for (const handler of handlers)
|
|
10275
6969
|
transactor.transactInputNow(path, e, handler, this.dragInfo);
|
|
10276
6970
|
}
|
|
10277
6971
|
_handleTouchEvent(e) {
|
|
10278
|
-
const { type
|
|
10279
|
-
if (
|
|
6972
|
+
const { type } = e;
|
|
6973
|
+
if (type === "touchstart") {
|
|
10280
6974
|
if (this._touch !== null || e.touches.length !== 1)
|
|
10281
6975
|
return;
|
|
10282
6976
|
const t = e.touches[0];
|
|
@@ -10293,11 +6987,11 @@ class App {
|
|
|
10293
6987
|
return;
|
|
10294
6988
|
const { rootNode, _touch } = this;
|
|
10295
6989
|
const { clientX, clientY } = touch;
|
|
10296
|
-
const fire = (
|
|
10297
|
-
const e2 = { type:
|
|
6990
|
+
const fire = (type2, target) => {
|
|
6991
|
+
const e2 = { type: type2, target, clientX, clientY, preventDefault: NOOP };
|
|
10298
6992
|
this._dispatchEvent(e2);
|
|
10299
6993
|
};
|
|
10300
|
-
if (
|
|
6994
|
+
if (type === "touchmove") {
|
|
10301
6995
|
if (!_touch.active) {
|
|
10302
6996
|
const dx = clientX - _touch.startX;
|
|
10303
6997
|
const dy = clientY - _touch.startY;
|
|
@@ -10312,17 +7006,17 @@ class App {
|
|
|
10312
7006
|
}
|
|
10313
7007
|
return;
|
|
10314
7008
|
}
|
|
10315
|
-
if (
|
|
7009
|
+
if (type === "touchend" || type === "touchcancel") {
|
|
10316
7010
|
if (_touch.active) {
|
|
10317
|
-
if (
|
|
7011
|
+
if (type === "touchend")
|
|
10318
7012
|
fire("drop", hitTest(rootNode, clientX, clientY));
|
|
10319
7013
|
fire("dragend", _touch.target);
|
|
10320
7014
|
}
|
|
10321
7015
|
this._touch = null;
|
|
10322
7016
|
}
|
|
10323
7017
|
}
|
|
10324
|
-
_handleDragEvent(e,
|
|
10325
|
-
if (
|
|
7018
|
+
_handleDragEvent(e, type, path) {
|
|
7019
|
+
if (type === "dragover") {
|
|
10326
7020
|
const dropTarget = getClosestDropTarget(e.target, this.rootNode, Infinity);
|
|
10327
7021
|
if (dropTarget !== null) {
|
|
10328
7022
|
e.preventDefault();
|
|
@@ -10330,7 +7024,7 @@ class App {
|
|
|
10330
7024
|
this.curDragOver = dropTarget;
|
|
10331
7025
|
dropTarget.dataset.draggingover = this.dragInfo?.type ?? "_external";
|
|
10332
7026
|
}
|
|
10333
|
-
} else if (
|
|
7027
|
+
} else if (type === "dragstart") {
|
|
10334
7028
|
e.target.dataset.dragging = 1;
|
|
10335
7029
|
const rootValue = this.state.val;
|
|
10336
7030
|
const txnPath = path.compact().toTransactionPath();
|
|
@@ -10338,7 +7032,7 @@ class App {
|
|
|
10338
7032
|
const dragType = e.target.dataset.dragtype ?? "?";
|
|
10339
7033
|
const stack = path.toTransactionPath().buildStack(this.makeStack(rootValue));
|
|
10340
7034
|
this.dragInfo = new DragInfo(txnPath, stack, e, value, dragType, e.target);
|
|
10341
|
-
} else if (
|
|
7035
|
+
} else if (type === "drop") {
|
|
10342
7036
|
e.preventDefault();
|
|
10343
7037
|
this._cleanDragOverAttrs();
|
|
10344
7038
|
} else {
|
|
@@ -10478,12 +7172,12 @@ function getClosestDropTarget(target, rootNode, count) {
|
|
|
10478
7172
|
}
|
|
10479
7173
|
|
|
10480
7174
|
class DragInfo {
|
|
10481
|
-
constructor(path, stack, e, val,
|
|
7175
|
+
constructor(path, stack, e, val, type, node) {
|
|
10482
7176
|
this.path = path;
|
|
10483
7177
|
this.stack = stack;
|
|
10484
7178
|
this.e = e;
|
|
10485
7179
|
this.val = val;
|
|
10486
|
-
this.type =
|
|
7180
|
+
this.type = type;
|
|
10487
7181
|
this.node = node;
|
|
10488
7182
|
}
|
|
10489
7183
|
lookupBind(name) {
|
|
@@ -10525,8 +7219,8 @@ var BAD_VALUE2 = Symbol("BadValue");
|
|
|
10525
7219
|
var nullCoercer = (v) => v;
|
|
10526
7220
|
|
|
10527
7221
|
class Field {
|
|
10528
|
-
constructor(
|
|
10529
|
-
this.type =
|
|
7222
|
+
constructor(type, name, typeCheck, coercer, defaultValue = null) {
|
|
7223
|
+
this.type = type;
|
|
10530
7224
|
this.name = name;
|
|
10531
7225
|
this.typeCheck = typeCheck;
|
|
10532
7226
|
this.coercer = coercer;
|
|
@@ -10534,8 +7228,8 @@ class Field {
|
|
|
10534
7228
|
this.defaultValue = defaultValue;
|
|
10535
7229
|
}
|
|
10536
7230
|
toDataDef() {
|
|
10537
|
-
const { type
|
|
10538
|
-
return { type
|
|
7231
|
+
const { type, defaultValue: dv } = this;
|
|
7232
|
+
return { type, defaultValue: dv?.toJS ? dv.toJS() : dv };
|
|
10539
7233
|
}
|
|
10540
7234
|
getFirstFailingCheck(v) {
|
|
10541
7235
|
if (!this.typeCheck.isValid(v))
|
|
@@ -10642,8 +7336,8 @@ class FieldAny extends Field {
|
|
|
10642
7336
|
}
|
|
10643
7337
|
toDataDef() {
|
|
10644
7338
|
const { defaultValue: dv } = this;
|
|
10645
|
-
const
|
|
10646
|
-
return { type
|
|
7339
|
+
const type = getTypeName(dv) ?? "any";
|
|
7340
|
+
return { type, defaultValue: dv?.toJS ? dv.toJS() : dv };
|
|
10647
7341
|
}
|
|
10648
7342
|
}
|
|
10649
7343
|
var stringCoercer = (v) => v?.toString?.() ?? "";
|
|
@@ -10686,8 +7380,8 @@ class CheckTypeName {
|
|
|
10686
7380
|
}
|
|
10687
7381
|
|
|
10688
7382
|
class FieldComp extends Field {
|
|
10689
|
-
constructor(
|
|
10690
|
-
super(
|
|
7383
|
+
constructor(type, name, args) {
|
|
7384
|
+
super(type, name, new CheckTypeName(type), nullCoercer, null);
|
|
10691
7385
|
this.args = args;
|
|
10692
7386
|
}
|
|
10693
7387
|
toDataDef() {
|
|
@@ -10846,8 +7540,8 @@ class ClassBuilder {
|
|
|
10846
7540
|
this.fields[name] = field;
|
|
10847
7541
|
return field;
|
|
10848
7542
|
}
|
|
10849
|
-
addCompField(name,
|
|
10850
|
-
const field = new FieldComp(
|
|
7543
|
+
addCompField(name, type, args) {
|
|
7544
|
+
const field = new FieldComp(type, name, args);
|
|
10851
7545
|
this.compFields.add(name);
|
|
10852
7546
|
this.fields[name] = field;
|
|
10853
7547
|
return field;
|
|
@@ -10869,12 +7563,12 @@ function classFromData(name, { fields = {}, methods, statics }) {
|
|
|
10869
7563
|
const b = new ClassBuilder(name);
|
|
10870
7564
|
for (const field in fields) {
|
|
10871
7565
|
const value = fields[field];
|
|
10872
|
-
const
|
|
10873
|
-
if (
|
|
7566
|
+
const type = typeof value;
|
|
7567
|
+
if (type === "string")
|
|
10874
7568
|
b.addField(field, value, FieldString);
|
|
10875
|
-
else if (
|
|
7569
|
+
else if (type === "number")
|
|
10876
7570
|
b.addField(field, value, FieldFloat);
|
|
10877
|
-
else if (
|
|
7571
|
+
else if (type === "boolean")
|
|
10878
7572
|
b.addField(field, value, FieldBool);
|
|
10879
7573
|
else if (List.isList(value) || Array.isArray(value))
|
|
10880
7574
|
b.addField(field, List(value), FieldList);
|
|
@@ -11233,7 +7927,7 @@ KList.prototype[SEQ_INFO] = (seq, visit) => {
|
|
|
11233
7927
|
var exports_tutuca = {};
|
|
11234
7928
|
__export(exports_tutuca, {
|
|
11235
7929
|
tutuca: () => tutuca,
|
|
11236
|
-
test: () =>
|
|
7930
|
+
test: () => test,
|
|
11237
7931
|
macro: () => macro,
|
|
11238
7932
|
isOMap: () => isOrderedMap,
|
|
11239
7933
|
isIMap: () => isMap,
|
|
@@ -11265,7 +7959,7 @@ var macro = (defaults, rawView) => new Macro(defaults, rawView);
|
|
|
11265
7959
|
function check(_app) {
|
|
11266
7960
|
return { error: 0, warn: 0, hint: 0, dummyCheck: true };
|
|
11267
7961
|
}
|
|
11268
|
-
async function
|
|
7962
|
+
async function test(_opts) {
|
|
11269
7963
|
return null;
|
|
11270
7964
|
}
|
|
11271
7965
|
function collectIterBindings() {
|
|
@@ -11318,7 +8012,7 @@ function getSignature(name, fn) {
|
|
|
11318
8012
|
return `${name}(${params})`;
|
|
11319
8013
|
}
|
|
11320
8014
|
function getFieldMethods(field) {
|
|
11321
|
-
const { name, type
|
|
8015
|
+
const { name, type } = field;
|
|
11322
8016
|
const uname = name[0].toUpperCase() + name.slice(1);
|
|
11323
8017
|
const methods = [
|
|
11324
8018
|
{ name: `set${uname}`, sig: `set${uname}(v)`, desc: "Set value" },
|
|
@@ -11333,7 +8027,7 @@ function getFieldMethods(field) {
|
|
|
11333
8027
|
desc: "Reset to default value"
|
|
11334
8028
|
}
|
|
11335
8029
|
];
|
|
11336
|
-
switch (
|
|
8030
|
+
switch (type) {
|
|
11337
8031
|
case "bool":
|
|
11338
8032
|
methods[0].desc = "Set value (coerces to boolean)";
|
|
11339
8033
|
methods.push({
|
|
@@ -11386,7 +8080,7 @@ function getFieldMethods(field) {
|
|
|
11386
8080
|
break;
|
|
11387
8081
|
case "map":
|
|
11388
8082
|
case "omap": {
|
|
11389
|
-
const label =
|
|
8083
|
+
const label = type === "omap" ? "ordered map" : "map";
|
|
11390
8084
|
methods.push({
|
|
11391
8085
|
name: `${name}Len`,
|
|
11392
8086
|
sig: `${name}Len()`,
|
|
@@ -11539,7 +8233,7 @@ function collectIterBindings2(Comp, compInstance, seq, opts = {}) {
|
|
|
11539
8233
|
}
|
|
11540
8234
|
|
|
11541
8235
|
// dev.js
|
|
11542
|
-
async function
|
|
8236
|
+
async function test3(opts = {}) {
|
|
11543
8237
|
const report = await runTests({ expect, ...opts });
|
|
11544
8238
|
reportTestReportToConsole(report);
|
|
11545
8239
|
return report;
|
|
@@ -11587,9 +8281,9 @@ class LintClassCollectorCtx extends ParseCtxClassSetCollector {
|
|
|
11587
8281
|
this.parseIssues = [];
|
|
11588
8282
|
}
|
|
11589
8283
|
enterMacro(macroName, macroVars, macroSlots) {
|
|
11590
|
-
const { document: document2, Text, Comment, nodes, events
|
|
8284
|
+
const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
|
|
11591
8285
|
const frame = { macroName, macroVars, macroSlots };
|
|
11592
|
-
const v = new LintClassCollectorCtx(document2, Text, Comment, nodes,
|
|
8286
|
+
const v = new LintClassCollectorCtx(document2, Text, Comment, nodes, events, macroNodes, frame, this);
|
|
11593
8287
|
v.classes = this.classes;
|
|
11594
8288
|
v.attrs = this.attrs;
|
|
11595
8289
|
v.parseIssues = this.parseIssues;
|
|
@@ -11606,7 +8300,7 @@ class LintClassCollectorCtx extends ParseCtxClassSetCollector {
|
|
|
11606
8300
|
}
|
|
11607
8301
|
export {
|
|
11608
8302
|
tutuca,
|
|
11609
|
-
|
|
8303
|
+
test3 as test,
|
|
11610
8304
|
suggestionToMessage,
|
|
11611
8305
|
runTests,
|
|
11612
8306
|
reportTestReportToConsole,
|