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