@gjsify/assert 0.3.13 → 0.3.15
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/lib/esm/assertion-error.js +56 -66
- package/lib/esm/deep-equal.js +434 -450
- package/lib/esm/index.js +384 -417
- package/lib/esm/inspect-fallback.js +69 -67
- package/lib/esm/strict/index.js +4 -43
- package/package.json +3 -3
package/lib/esm/index.js
CHANGED
|
@@ -1,464 +1,431 @@
|
|
|
1
1
|
import { AssertionError } from "./assertion-error.js";
|
|
2
2
|
import { isDeepEqual, isDeepStrictEqual } from "./deep-equal.js";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
3
5
|
function innerFail(obj) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if (obj.message instanceof Error) throw obj.message;
|
|
7
|
+
throw new AssertionError({
|
|
8
|
+
actual: obj.actual,
|
|
9
|
+
expected: obj.expected,
|
|
10
|
+
message: obj.message,
|
|
11
|
+
operator: obj.operator,
|
|
12
|
+
stackStartFn: obj.stackStartFn
|
|
13
|
+
});
|
|
12
14
|
}
|
|
13
15
|
function isPromiseLike(val) {
|
|
14
|
-
|
|
16
|
+
return val !== null && typeof val === "object" && typeof val.then === "function";
|
|
15
17
|
}
|
|
16
18
|
function ok(value, message) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (!value) {
|
|
20
|
+
innerFail({
|
|
21
|
+
actual: value,
|
|
22
|
+
expected: true,
|
|
23
|
+
message,
|
|
24
|
+
operator: "==",
|
|
25
|
+
stackStartFn: ok
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
function equal(actual, expected, message) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
if (actual != expected) {
|
|
31
|
+
innerFail({
|
|
32
|
+
actual,
|
|
33
|
+
expected,
|
|
34
|
+
message,
|
|
35
|
+
operator: "==",
|
|
36
|
+
stackStartFn: equal
|
|
37
|
+
});
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
function notEqual(actual, expected, message) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
if (actual == expected) {
|
|
42
|
+
innerFail({
|
|
43
|
+
actual,
|
|
44
|
+
expected,
|
|
45
|
+
message,
|
|
46
|
+
operator: "!=",
|
|
47
|
+
stackStartFn: notEqual
|
|
48
|
+
});
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
function strictEqual(actual, expected, message) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
if (!Object.is(actual, expected)) {
|
|
53
|
+
innerFail({
|
|
54
|
+
actual,
|
|
55
|
+
expected,
|
|
56
|
+
message,
|
|
57
|
+
operator: "strictEqual",
|
|
58
|
+
stackStartFn: strictEqual
|
|
59
|
+
});
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
function notStrictEqual(actual, expected, message) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
if (Object.is(actual, expected)) {
|
|
64
|
+
innerFail({
|
|
65
|
+
actual,
|
|
66
|
+
expected,
|
|
67
|
+
message,
|
|
68
|
+
operator: "notStrictEqual",
|
|
69
|
+
stackStartFn: notStrictEqual
|
|
70
|
+
});
|
|
71
|
+
}
|
|
70
72
|
}
|
|
71
73
|
function deepEqual(actual, expected, message) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
if (!isDeepEqual(actual, expected)) {
|
|
75
|
+
innerFail({
|
|
76
|
+
actual,
|
|
77
|
+
expected,
|
|
78
|
+
message,
|
|
79
|
+
operator: "deepEqual",
|
|
80
|
+
stackStartFn: deepEqual
|
|
81
|
+
});
|
|
82
|
+
}
|
|
81
83
|
}
|
|
82
84
|
function notDeepEqual(actual, expected, message) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
if (isDeepEqual(actual, expected)) {
|
|
86
|
+
innerFail({
|
|
87
|
+
actual,
|
|
88
|
+
expected,
|
|
89
|
+
message,
|
|
90
|
+
operator: "notDeepEqual",
|
|
91
|
+
stackStartFn: notDeepEqual
|
|
92
|
+
});
|
|
93
|
+
}
|
|
92
94
|
}
|
|
93
95
|
function deepStrictEqual(actual, expected, message) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
if (!isDeepStrictEqual(actual, expected)) {
|
|
97
|
+
innerFail({
|
|
98
|
+
actual,
|
|
99
|
+
expected,
|
|
100
|
+
message,
|
|
101
|
+
operator: "deepStrictEqual",
|
|
102
|
+
stackStartFn: deepStrictEqual
|
|
103
|
+
});
|
|
104
|
+
}
|
|
103
105
|
}
|
|
104
106
|
function notDeepStrictEqual(actual, expected, message) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
if (isDeepStrictEqual(actual, expected)) {
|
|
108
|
+
innerFail({
|
|
109
|
+
actual,
|
|
110
|
+
expected,
|
|
111
|
+
message,
|
|
112
|
+
operator: "notDeepStrictEqual",
|
|
113
|
+
stackStartFn: notDeepStrictEqual
|
|
114
|
+
});
|
|
115
|
+
}
|
|
114
116
|
}
|
|
115
117
|
function getActual(fn) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
const NO_EXCEPTION = Symbol("NO_EXCEPTION");
|
|
119
|
+
try {
|
|
120
|
+
fn();
|
|
121
|
+
} catch (e) {
|
|
122
|
+
return e;
|
|
123
|
+
}
|
|
124
|
+
return NO_EXCEPTION;
|
|
123
125
|
}
|
|
124
126
|
async function getActualAsync(fn) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
const NO_EXCEPTION = Symbol("NO_EXCEPTION");
|
|
128
|
+
try {
|
|
129
|
+
if (typeof fn === "function") {
|
|
130
|
+
const result = fn();
|
|
131
|
+
if (isPromiseLike(result)) {
|
|
132
|
+
await result;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
await fn;
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return e;
|
|
139
|
+
}
|
|
140
|
+
return NO_EXCEPTION;
|
|
139
141
|
}
|
|
140
142
|
function expectedException(actual, expected, message, fn) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
143
|
+
if (expected === undefined) return true;
|
|
144
|
+
if (expected instanceof RegExp) {
|
|
145
|
+
const str = String(actual);
|
|
146
|
+
if (expected.test(str)) return true;
|
|
147
|
+
throw new AssertionError({
|
|
148
|
+
actual,
|
|
149
|
+
expected,
|
|
150
|
+
message,
|
|
151
|
+
operator: fn.name,
|
|
152
|
+
stackStartFn: fn
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (typeof expected === "function") {
|
|
156
|
+
if (expected.prototype !== undefined && actual instanceof expected) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (Error.isPrototypeOf(expected)) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
const result = expected.call({}, actual);
|
|
163
|
+
if (result !== true) {
|
|
164
|
+
throw new AssertionError({
|
|
165
|
+
actual,
|
|
166
|
+
expected,
|
|
167
|
+
message,
|
|
168
|
+
operator: fn.name,
|
|
169
|
+
stackStartFn: fn
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
if (typeof expected === "object" && expected !== null) {
|
|
175
|
+
const keys = Object.keys(expected);
|
|
176
|
+
for (const key of keys) {
|
|
177
|
+
const expectedObj = expected;
|
|
178
|
+
const actualObj = actual;
|
|
179
|
+
if (typeof actualObj[key] === "string" && expectedObj[key] instanceof RegExp) {
|
|
180
|
+
if (!expectedObj[key].test(actualObj[key])) {
|
|
181
|
+
throw new AssertionError({
|
|
182
|
+
actual,
|
|
183
|
+
expected,
|
|
184
|
+
message,
|
|
185
|
+
operator: fn.name,
|
|
186
|
+
stackStartFn: fn
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
} else if (!isDeepStrictEqual(actualObj[key], expectedObj[key])) {
|
|
190
|
+
throw new AssertionError({
|
|
191
|
+
actual,
|
|
192
|
+
expected,
|
|
193
|
+
message,
|
|
194
|
+
operator: fn.name,
|
|
195
|
+
stackStartFn: fn
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
200
202
|
}
|
|
201
203
|
function throws(fn, errorOrMessage, message) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
if (typeof fn !== "function") {
|
|
205
|
+
throw new TypeError("The \"fn\" argument must be of type function.");
|
|
206
|
+
}
|
|
207
|
+
let expected;
|
|
208
|
+
if (typeof errorOrMessage === "string") {
|
|
209
|
+
message = errorOrMessage;
|
|
210
|
+
expected = undefined;
|
|
211
|
+
} else {
|
|
212
|
+
expected = errorOrMessage;
|
|
213
|
+
}
|
|
214
|
+
const actual = getActual(fn);
|
|
215
|
+
if (typeof actual === "symbol") {
|
|
216
|
+
innerFail({
|
|
217
|
+
actual: undefined,
|
|
218
|
+
expected,
|
|
219
|
+
message: message || "Missing expected exception.",
|
|
220
|
+
operator: "throws",
|
|
221
|
+
stackStartFn: throws
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (expected !== undefined) {
|
|
225
|
+
expectedException(actual, expected, message, throws);
|
|
226
|
+
}
|
|
225
227
|
}
|
|
226
228
|
function doesNotThrow(fn, errorOrMessage, message) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
throw actual;
|
|
229
|
+
if (typeof fn !== "function") {
|
|
230
|
+
throw new TypeError("The \"fn\" argument must be of type function.");
|
|
231
|
+
}
|
|
232
|
+
let expected;
|
|
233
|
+
if (typeof errorOrMessage === "string") {
|
|
234
|
+
message = errorOrMessage;
|
|
235
|
+
expected = undefined;
|
|
236
|
+
} else {
|
|
237
|
+
expected = errorOrMessage;
|
|
238
|
+
}
|
|
239
|
+
const actual = getActual(fn);
|
|
240
|
+
if (typeof actual === "symbol") {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (expected !== undefined && typeof expected === "function" && expected.prototype !== undefined && actual instanceof expected) {
|
|
244
|
+
innerFail({
|
|
245
|
+
actual,
|
|
246
|
+
expected,
|
|
247
|
+
message: message || `Got unwanted exception.\n${actual && actual.message ? actual.message : ""}`,
|
|
248
|
+
operator: "doesNotThrow",
|
|
249
|
+
stackStartFn: doesNotThrow
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (expected === undefined || typeof expected === "function" && expected.prototype !== undefined && actual instanceof expected) {
|
|
253
|
+
innerFail({
|
|
254
|
+
actual,
|
|
255
|
+
expected,
|
|
256
|
+
message: message || `Got unwanted exception.\n${actual && actual.message ? actual.message : ""}`,
|
|
257
|
+
operator: "doesNotThrow",
|
|
258
|
+
stackStartFn: doesNotThrow
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
throw actual;
|
|
262
262
|
}
|
|
263
263
|
async function rejects(asyncFn, errorOrMessage, message) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
264
|
+
let expected;
|
|
265
|
+
if (typeof errorOrMessage === "string") {
|
|
266
|
+
message = errorOrMessage;
|
|
267
|
+
expected = undefined;
|
|
268
|
+
} else {
|
|
269
|
+
expected = errorOrMessage;
|
|
270
|
+
}
|
|
271
|
+
const actual = await getActualAsync(asyncFn);
|
|
272
|
+
if (typeof actual === "symbol") {
|
|
273
|
+
innerFail({
|
|
274
|
+
actual: undefined,
|
|
275
|
+
expected,
|
|
276
|
+
message: message || "Missing expected rejection.",
|
|
277
|
+
operator: "rejects",
|
|
278
|
+
stackStartFn: rejects
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
if (expected !== undefined) {
|
|
282
|
+
expectedException(actual, expected, message, rejects);
|
|
283
|
+
}
|
|
284
284
|
}
|
|
285
285
|
async function doesNotReject(asyncFn, errorOrMessage, message) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
286
|
+
let expected;
|
|
287
|
+
if (typeof errorOrMessage === "string") {
|
|
288
|
+
message = errorOrMessage;
|
|
289
|
+
expected = undefined;
|
|
290
|
+
} else {
|
|
291
|
+
expected = errorOrMessage;
|
|
292
|
+
}
|
|
293
|
+
const actual = await getActualAsync(asyncFn);
|
|
294
|
+
if (typeof actual !== "symbol") {
|
|
295
|
+
innerFail({
|
|
296
|
+
actual,
|
|
297
|
+
expected,
|
|
298
|
+
message: message || `Got unwanted rejection.\n${actual && actual.message ? actual.message : ""}`,
|
|
299
|
+
operator: "doesNotReject",
|
|
300
|
+
stackStartFn: doesNotReject
|
|
301
|
+
});
|
|
302
|
+
}
|
|
304
303
|
}
|
|
305
304
|
function fail(actualOrMessage, expected, message, operator, stackStartFn) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
305
|
+
if (arguments.length === 0 || arguments.length === 1) {
|
|
306
|
+
const msg = arguments.length === 0 ? "Failed" : typeof actualOrMessage === "string" ? actualOrMessage : undefined;
|
|
307
|
+
if (actualOrMessage instanceof Error) throw actualOrMessage;
|
|
308
|
+
throw new AssertionError({
|
|
309
|
+
message: msg || "Failed",
|
|
310
|
+
operator: "fail",
|
|
311
|
+
stackStartFn: fail
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
throw new AssertionError({
|
|
315
|
+
actual: actualOrMessage,
|
|
316
|
+
expected,
|
|
317
|
+
message,
|
|
318
|
+
operator: operator || "fail",
|
|
319
|
+
stackStartFn: stackStartFn || fail
|
|
320
|
+
});
|
|
322
321
|
}
|
|
323
322
|
function ifError(value) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
323
|
+
if (value !== null && value !== undefined) {
|
|
324
|
+
let message = "ifError got unwanted exception: ";
|
|
325
|
+
if (typeof value === "object" && typeof value.message === "string") {
|
|
326
|
+
if (value.message.length === 0 && value.constructor) {
|
|
327
|
+
message += value.constructor.name;
|
|
328
|
+
} else {
|
|
329
|
+
message += value.message;
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
message += String(value);
|
|
333
|
+
}
|
|
334
|
+
const err = new AssertionError({
|
|
335
|
+
actual: value,
|
|
336
|
+
expected: null,
|
|
337
|
+
message,
|
|
338
|
+
operator: "ifError",
|
|
339
|
+
stackStartFn: ifError
|
|
340
|
+
});
|
|
341
|
+
const origStack = value instanceof Error ? value.stack : undefined;
|
|
342
|
+
if (origStack) {
|
|
343
|
+
err.origStack = origStack;
|
|
344
|
+
}
|
|
345
|
+
throw err;
|
|
346
|
+
}
|
|
348
347
|
}
|
|
349
348
|
function match(actual, expected, message) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
stackStartFn: match
|
|
366
|
-
});
|
|
367
|
-
}
|
|
349
|
+
if (typeof actual !== "string") {
|
|
350
|
+
throw new TypeError("The \"actual\" argument must be of type string.");
|
|
351
|
+
}
|
|
352
|
+
if (!(expected instanceof RegExp)) {
|
|
353
|
+
throw new TypeError("The \"expected\" argument must be an instance of RegExp.");
|
|
354
|
+
}
|
|
355
|
+
if (!expected.test(actual)) {
|
|
356
|
+
innerFail({
|
|
357
|
+
actual,
|
|
358
|
+
expected,
|
|
359
|
+
message: message || `The input did not match the regular expression ${expected}. Input:\n\n'${actual}'\n`,
|
|
360
|
+
operator: "match",
|
|
361
|
+
stackStartFn: match
|
|
362
|
+
});
|
|
363
|
+
}
|
|
368
364
|
}
|
|
369
365
|
function doesNotMatch(actual, expected, message) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
stackStartFn: doesNotMatch
|
|
386
|
-
});
|
|
387
|
-
}
|
|
366
|
+
if (typeof actual !== "string") {
|
|
367
|
+
throw new TypeError("The \"actual\" argument must be of type string.");
|
|
368
|
+
}
|
|
369
|
+
if (!(expected instanceof RegExp)) {
|
|
370
|
+
throw new TypeError("The \"expected\" argument must be an instance of RegExp.");
|
|
371
|
+
}
|
|
372
|
+
if (expected.test(actual)) {
|
|
373
|
+
innerFail({
|
|
374
|
+
actual,
|
|
375
|
+
expected,
|
|
376
|
+
message: message || `The input was expected to not match the regular expression ${expected}. Input:\n\n'${actual}'\n`,
|
|
377
|
+
operator: "doesNotMatch",
|
|
378
|
+
stackStartFn: doesNotMatch
|
|
379
|
+
});
|
|
380
|
+
}
|
|
388
381
|
}
|
|
389
|
-
const strict = Object.assign(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
strict: void 0
|
|
413
|
-
}
|
|
414
|
-
);
|
|
382
|
+
const strict = Object.assign(function strict(value, message) {
|
|
383
|
+
ok(value, message);
|
|
384
|
+
}, {
|
|
385
|
+
AssertionError,
|
|
386
|
+
ok,
|
|
387
|
+
equal: strictEqual,
|
|
388
|
+
notEqual: notStrictEqual,
|
|
389
|
+
deepEqual: deepStrictEqual,
|
|
390
|
+
notDeepEqual: notDeepStrictEqual,
|
|
391
|
+
deepStrictEqual,
|
|
392
|
+
notDeepStrictEqual,
|
|
393
|
+
strictEqual,
|
|
394
|
+
notStrictEqual,
|
|
395
|
+
throws,
|
|
396
|
+
doesNotThrow,
|
|
397
|
+
rejects,
|
|
398
|
+
doesNotReject,
|
|
399
|
+
fail,
|
|
400
|
+
ifError,
|
|
401
|
+
match,
|
|
402
|
+
doesNotMatch,
|
|
403
|
+
strict: undefined
|
|
404
|
+
});
|
|
415
405
|
strict.strict = strict;
|
|
416
|
-
const assert = Object.assign(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
var index_default = assert;
|
|
443
|
-
export {
|
|
444
|
-
AssertionError,
|
|
445
|
-
deepEqual,
|
|
446
|
-
deepStrictEqual,
|
|
447
|
-
index_default as default,
|
|
448
|
-
doesNotMatch,
|
|
449
|
-
doesNotReject,
|
|
450
|
-
doesNotThrow,
|
|
451
|
-
equal,
|
|
452
|
-
fail,
|
|
453
|
-
ifError,
|
|
454
|
-
match,
|
|
455
|
-
notDeepEqual,
|
|
456
|
-
notDeepStrictEqual,
|
|
457
|
-
notEqual,
|
|
458
|
-
notStrictEqual,
|
|
459
|
-
ok,
|
|
460
|
-
rejects,
|
|
461
|
-
strict,
|
|
462
|
-
strictEqual,
|
|
463
|
-
throws
|
|
464
|
-
};
|
|
406
|
+
const assert = Object.assign(function assert(value, message) {
|
|
407
|
+
ok(value, message);
|
|
408
|
+
}, {
|
|
409
|
+
AssertionError,
|
|
410
|
+
ok,
|
|
411
|
+
equal,
|
|
412
|
+
notEqual,
|
|
413
|
+
strictEqual,
|
|
414
|
+
notStrictEqual,
|
|
415
|
+
deepEqual,
|
|
416
|
+
notDeepEqual,
|
|
417
|
+
deepStrictEqual,
|
|
418
|
+
notDeepStrictEqual,
|
|
419
|
+
throws,
|
|
420
|
+
doesNotThrow,
|
|
421
|
+
rejects,
|
|
422
|
+
doesNotReject,
|
|
423
|
+
fail,
|
|
424
|
+
ifError,
|
|
425
|
+
match,
|
|
426
|
+
doesNotMatch,
|
|
427
|
+
strict
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
//#endregion
|
|
431
|
+
export { AssertionError, deepEqual, deepStrictEqual, assert as default, doesNotMatch, doesNotReject, doesNotThrow, equal, fail, ifError, match, notDeepEqual, notDeepStrictEqual, notEqual, notStrictEqual, ok, rejects, strict, strictEqual, throws };
|