@plugjs/expect5 0.4.4 → 0.4.6

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.
Files changed (90) hide show
  1. package/dist/cli.mjs +2 -2
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/execution/executor.cjs.map +1 -1
  4. package/dist/execution/executor.d.ts +1 -1
  5. package/dist/execution/executor.mjs +1 -1
  6. package/dist/execution/executor.mjs.map +1 -1
  7. package/dist/execution/setup.cjs.map +1 -1
  8. package/dist/execution/setup.d.ts +1 -1
  9. package/dist/execution/setup.mjs +1 -1
  10. package/dist/execution/setup.mjs.map +1 -1
  11. package/dist/expectation/async.cjs +78 -45
  12. package/dist/expectation/async.cjs.map +1 -1
  13. package/dist/expectation/async.d.ts +66 -51
  14. package/dist/expectation/async.mjs +79 -42
  15. package/dist/expectation/async.mjs.map +1 -1
  16. package/dist/expectation/diff.cjs.map +1 -1
  17. package/dist/expectation/diff.mjs +6 -1
  18. package/dist/expectation/diff.mjs.map +1 -1
  19. package/dist/expectation/expect.cjs +11 -165
  20. package/dist/expectation/expect.cjs.map +2 -2
  21. package/dist/expectation/expect.d.ts +10 -112
  22. package/dist/expectation/expect.mjs +12 -207
  23. package/dist/expectation/expect.mjs.map +2 -2
  24. package/dist/expectation/expectations.cjs +549 -0
  25. package/dist/expectation/expectations.cjs.map +6 -0
  26. package/dist/expectation/expectations.d.ts +454 -0
  27. package/dist/expectation/expectations.mjs +530 -0
  28. package/dist/expectation/expectations.mjs.map +6 -0
  29. package/dist/expectation/include.cjs +43 -41
  30. package/dist/expectation/include.cjs.map +1 -1
  31. package/dist/expectation/include.d.ts +3 -19
  32. package/dist/expectation/include.mjs +43 -41
  33. package/dist/expectation/include.mjs.map +1 -1
  34. package/dist/expectation/matchers.cjs +350 -0
  35. package/dist/expectation/matchers.cjs.map +6 -0
  36. package/dist/expectation/matchers.d.ts +375 -0
  37. package/dist/expectation/matchers.mjs +328 -0
  38. package/dist/expectation/matchers.mjs.map +6 -0
  39. package/dist/expectation/print.cjs.map +1 -1
  40. package/dist/expectation/print.d.ts +2 -2
  41. package/dist/expectation/print.mjs.map +1 -1
  42. package/dist/expectation/types.cjs +17 -23
  43. package/dist/expectation/types.cjs.map +1 -1
  44. package/dist/expectation/types.d.ts +7 -51
  45. package/dist/expectation/types.mjs +17 -22
  46. package/dist/expectation/types.mjs.map +1 -1
  47. package/dist/globals.d.ts +2 -2
  48. package/dist/index.cjs +5 -5
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.ts +3 -4
  51. package/dist/index.mjs +11 -12
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/test.cjs +33 -5
  54. package/dist/test.cjs.map +1 -1
  55. package/dist/test.d.ts +2 -2
  56. package/dist/test.mjs +34 -6
  57. package/dist/test.mjs.map +1 -1
  58. package/package.json +2 -2
  59. package/src/cli.mts +1 -1
  60. package/src/execution/executor.ts +1 -3
  61. package/src/execution/setup.ts +1 -3
  62. package/src/expectation/async.ts +145 -145
  63. package/src/expectation/diff.ts +7 -3
  64. package/src/expectation/expect.ts +22 -362
  65. package/src/expectation/expectations.ts +971 -0
  66. package/src/expectation/include.ts +59 -75
  67. package/src/expectation/matchers.ts +698 -0
  68. package/src/expectation/print.ts +8 -4
  69. package/src/expectation/types.ts +22 -94
  70. package/src/globals.ts +2 -2
  71. package/src/index.ts +17 -10
  72. package/src/test.ts +33 -10
  73. package/dist/expectation/basic.cjs +0 -188
  74. package/dist/expectation/basic.cjs.map +0 -6
  75. package/dist/expectation/basic.d.ts +0 -90
  76. package/dist/expectation/basic.mjs +0 -156
  77. package/dist/expectation/basic.mjs.map +0 -6
  78. package/dist/expectation/throwing.cjs +0 -58
  79. package/dist/expectation/throwing.cjs.map +0 -6
  80. package/dist/expectation/throwing.d.ts +0 -36
  81. package/dist/expectation/throwing.mjs +0 -32
  82. package/dist/expectation/throwing.mjs.map +0 -6
  83. package/dist/expectation/trivial.cjs +0 -96
  84. package/dist/expectation/trivial.cjs.map +0 -6
  85. package/dist/expectation/trivial.d.ts +0 -13
  86. package/dist/expectation/trivial.mjs +0 -61
  87. package/dist/expectation/trivial.mjs.map +0 -6
  88. package/src/expectation/basic.ts +0 -413
  89. package/src/expectation/throwing.ts +0 -106
  90. package/src/expectation/trivial.ts +0 -107
@@ -0,0 +1,698 @@
1
+ import {
2
+ Expectations,
3
+ type AssertedType,
4
+ type AssertionFunction,
5
+ type NegativeExpectations,
6
+ type InferMatchers,
7
+ } from './expectations'
8
+ import {
9
+ matcherMarker,
10
+ type Constructor,
11
+ type TypeMappings,
12
+ type TypeName,
13
+ } from './types'
14
+
15
+ type Matcher = (expectations: Expectations) => Expectations
16
+ type NegativeMatcher = (expectations: NegativeExpectations) => Expectations
17
+
18
+ /* ========================================================================== *
19
+ * EXPECTATIONS *
20
+ * ========================================================================== */
21
+
22
+ export class Matchers<T = unknown> {
23
+ private readonly _matchers: Matcher[]
24
+ readonly not: NegativeMatchers<T>
25
+
26
+ constructor() {
27
+ const matchers: Matcher[] = []
28
+ this.not = new NegativeMatchers(this, matchers)
29
+ this._matchers = matchers
30
+ }
31
+
32
+ expect(value: unknown): T {
33
+ let expectations = new Expectations(value, undefined)
34
+ for (const matcher of this._matchers) {
35
+ expectations = matcher(expectations)
36
+ }
37
+ return expectations.value as T
38
+ }
39
+
40
+ private _push(matcher: Matcher): Matchers<any> {
41
+ const matchers = new Matchers()
42
+ matchers._matchers.push(...this._matchers, matcher)
43
+ return matchers
44
+ }
45
+
46
+ static {
47
+ (this.prototype as any)[matcherMarker] = matcherMarker
48
+ }
49
+
50
+ /* ------------------------------------------------------------------------ *
51
+ * BASIC *
52
+ * ------------------------------------------------------------------------ */
53
+
54
+ /**
55
+ * Expects the value to be of the specified _extended_ {@link TypeName type},
56
+ * and (if specified) further asserts it with an {@link AssertionFunction}.
57
+ *
58
+ * Negation: {@link NegativeMatchers.toBeA `not.toBeA(...)`}
59
+ */
60
+ toBeA<
61
+ Name extends TypeName,
62
+ Mapped extends TypeMappings[Name],
63
+ Assert extends AssertionFunction<Mapped>,
64
+ >(
65
+ type: Name,
66
+ assertion?: Assert,
67
+ ): Matchers<AssertedType<Mapped, Assert>> {
68
+ return this._push((e) => e.toBeA(type, assertion as AssertionFunction))
69
+ }
70
+
71
+ /* ------------------------------------------------------------------------ */
72
+
73
+ /**
74
+ * Expects the value to be a `number` within a given +/- _delta_ range of the
75
+ * specified expected value.
76
+ *
77
+ * Negation: {@link NegativeMatchers.toBeCloseTo `not.toBeCloseTo(...)`}
78
+ */
79
+ toBeCloseTo(value: number, delta: number): Matchers<number>
80
+
81
+ /**
82
+ * Expects the value to be a `bigint` within a given +/- _delta_ range of the
83
+ * specified expected value.
84
+ *
85
+ * Negation: {@link NegativeMatchers.toBeCloseTo `not.toBeCloseTo(...)`}
86
+ */
87
+ toBeCloseTo(value: bigint, delta: bigint): Matchers<bigint>
88
+
89
+ /**
90
+ * Expects the value to be a `number` or `bigint` within a given +/- _delta_
91
+ * range of the specified expected value.
92
+ *
93
+ * Negation: {@link NegativeMatchers.toBeCloseTo `not.toBeCloseTo(...)`}
94
+ */
95
+ toBeCloseTo(
96
+ value: number | bigint,
97
+ delta: number | bigint,
98
+ ): Matchers {
99
+ return this._push((e) => e.toBeCloseTo(value as number, delta as number))
100
+ }
101
+
102
+ /* ------------------------------------------------------------------------ */
103
+
104
+ /**
105
+ * Expects the value to be neither `null` nor `undefined`.
106
+ *
107
+ * Negation: {@link NegativeMatchers.toBeDefined `not.toBeDefined()`}
108
+ */
109
+ toBeDefined(): Matchers<T> {
110
+ return this._push((e) => e.toBeDefined())
111
+ }
112
+
113
+
114
+ /* ------------------------------------------------------------------------ */
115
+
116
+ /**
117
+ * Expect the value to be an instance of {@link Error}.
118
+ *
119
+ * If specified, the {@link Error}'s own message will be further expected to
120
+ * either match the specified {@link RegExp}, or equal the specified `string`.
121
+ */
122
+ toBeError(
123
+ message?: string | RegExp
124
+ ): Matchers<Error>
125
+
126
+ /**
127
+ * Expect the value to be an instance of {@link Error} and further asserts
128
+ * it to be an instance of the specifed {@link Error} {@link Constructor}.
129
+ *
130
+ * If specified, the {@link Error}'s own message will be further expected to
131
+ * either match the specified {@link RegExp}, or equal the specified `string`.
132
+ */
133
+ toBeError<Class extends Constructor<Error>>(
134
+ constructor: Class,
135
+ message?: string | RegExp,
136
+ ): Matchers<InstanceType<Class>>
137
+
138
+ toBeError(
139
+ constructorOrMessage?: string | RegExp | Constructor,
140
+ maybeMessage?: string | RegExp,
141
+ ): Matchers {
142
+ const [ constructor, message ] =
143
+ typeof constructorOrMessage === 'function' ?
144
+ [ constructorOrMessage, maybeMessage ] :
145
+ [ Error, constructorOrMessage ]
146
+ return this._push((e) => e.toBeError(constructor, message))
147
+ }
148
+
149
+ /* ------------------------------------------------------------------------ */
150
+
151
+ /** Expects the value strictly equal to `false`. */
152
+ toBeFalse(): Matchers<false> {
153
+ return this._push((e) => e.toBeFalse())
154
+ }
155
+
156
+ /* ------------------------------------------------------------------------ */
157
+
158
+ /**
159
+ * Expects the value to be _falsy_ (zero, empty string, `false`, ...).
160
+ *
161
+ * Negation: {@link Matchers.toBeTruthy `toBeTruthy()`}
162
+ */
163
+ toBeFalsy(): Matchers<T> {
164
+ return this._push((e) => e.toBeFalsy())
165
+ }
166
+
167
+ /* ------------------------------------------------------------------------ */
168
+
169
+ /**
170
+ * Expects the value to be a `number` greater than the specified* expected
171
+ * value.
172
+ *
173
+ * Negation: {@link Matchers.toBeLessThanOrEqual `toBeLessThanOrEqual(...)`}
174
+ */
175
+ toBeGreaterThan(value: number): Matchers<number>
176
+
177
+ /**
178
+ * Expects the value to be a `bigint` greater than the specified expected
179
+ * value.
180
+ *
181
+ * Negation: {@link Matchers.toBeLessThanOrEqual `toBeLessThanOrEqual(...)`}
182
+ */
183
+ toBeGreaterThan(value: bigint): Matchers<bigint>
184
+
185
+ toBeGreaterThan(value: number | bigint): Matchers {
186
+ return this._push((e) => e.toBeGreaterThan(value as number))
187
+ }
188
+
189
+ /* ------------------------------------------------------------------------ */
190
+
191
+ /**
192
+ * Expects the value to be a `number` greater than or equal to the specified
193
+ * expected value.
194
+ *
195
+ * Negation: {@link Matchers.toBeLessThan `toBeLessThan(...)`}
196
+ */
197
+ toBeGreaterThanOrEqual(value: number): Matchers<number>
198
+
199
+ /**
200
+ * Expects the value to be a `bigint` greater than or equal to the specified
201
+ * expected value.
202
+ *
203
+ * Negation: {@link Matchers.toBeLessThan `toBeLessThan(...)`}
204
+ */
205
+ toBeGreaterThanOrEqual(value: bigint): Matchers<bigint>
206
+
207
+ toBeGreaterThanOrEqual(value: number | bigint): Matchers {
208
+ return this._push((e) => e.toBeGreaterThanOrEqual(value as number))
209
+ }
210
+
211
+ /* ------------------------------------------------------------------------ */
212
+
213
+ /**
214
+ * Expects the value to be an instance of the specified {@link Constructor},
215
+ * and (if specified) further asserts it with an {@link AssertionFunction}.
216
+ *
217
+ * Negation: {@link NegativeMatchers.toBeInstanceOf `not.toInstanceOf(...)`}
218
+ */
219
+ toBeInstanceOf<
220
+ Class extends Constructor,
221
+ Assert extends AssertionFunction<InstanceType<Class>>,
222
+ >(
223
+ constructor: Class,
224
+ assertion?: Assert,
225
+ ): Matchers<AssertedType<InstanceType<Class>, Assert>> {
226
+ return this._push((e) => e.toBeInstanceOf(constructor, assertion as AssertionFunction))
227
+ }
228
+
229
+ /* ------------------------------------------------------------------------ */
230
+
231
+ /**
232
+ * Expects the value to be a `number` less than the specified expected value.
233
+ *
234
+ * Negation: {@link Matchers.toBeGreaterThanOrEqual `toBeGreaterThanOrEqual(...)`}
235
+ */
236
+ toBeLessThan(value: number): Matchers<number>
237
+
238
+ /**
239
+ * Expects the value to be a `bigint` less than the specified expected value.
240
+ *
241
+ * Negation: {@link Matchers.toBeGreaterThanOrEqual `toBeGreaterThanOrEqual(...)`}
242
+ */
243
+ toBeLessThan(value: bigint): Matchers<bigint>
244
+
245
+ toBeLessThan(value: number | bigint): Matchers {
246
+ return this._push((e) => e.toBeLessThan(value as number))
247
+ }
248
+
249
+ /* ------------------------------------------------------------------------ */
250
+
251
+ /**
252
+ * Expects the value to be a `number` less than or equal to* the specified
253
+ * expected value.
254
+ *
255
+ * Negation: {@link Matchers.toBeGreaterThan `toBeGreaterThan(...)`}
256
+ */
257
+ toBeLessThanOrEqual(value: number): Matchers<number>
258
+
259
+ /**
260
+ * Expects the value to be a `bigint` less than or equal to the specified
261
+ * expected value.
262
+ *
263
+ * Negation: {@link Matchers.toBeGreaterThan `toBeGreaterThan(...)`}
264
+ */
265
+ toBeLessThanOrEqual(value: bigint): Matchers<bigint>
266
+
267
+ toBeLessThanOrEqual(value: number | bigint): Matchers {
268
+ return this._push((e) => e.toBeLessThanOrEqual(value as number))
269
+ }
270
+
271
+ /* ------------------------------------------------------------------------ */
272
+
273
+ /**
274
+ * Expects the value to be `NaN`.
275
+ *
276
+ * Negation: {@link NegativeMatchers.toBeNaN `not.toBeNaN()`}
277
+ */
278
+ toBeNaN(): Matchers<number> {
279
+ return this._push((e) => e.toBeNaN())
280
+ }
281
+
282
+ /* ------------------------------------------------------------------------ */
283
+
284
+ /** Expects the value to strictly equal `null`. */
285
+ toBeNull(): Matchers<null> {
286
+ return this._push((e) => e.toBeNull())
287
+ }
288
+
289
+ /* ------------------------------------------------------------------------ */
290
+
291
+ /** Expects the value to strictly equal `true`. */
292
+ toBeTrue(): Matchers<true> {
293
+ return this._push((e) => e.toBeTrue())
294
+ }
295
+
296
+ /* ------------------------------------------------------------------------ */
297
+
298
+ /**
299
+ * Expects the value to be _falsy_ (non-zero, non-empty string, ...).
300
+ *
301
+ * Negation: {@link Matchers.toBeFalsy `toBeFalsy()`}
302
+ */
303
+ toBeTruthy(): Matchers<T> {
304
+ return this._push((e) => e.toBeTruthy())
305
+ }
306
+
307
+ /* ------------------------------------------------------------------------ */
308
+
309
+ /** Expects the value to strictly equal `undefined`. */
310
+ toBeUndefined(): Matchers<undefined> {
311
+ return this._push((e) => e.toBeUndefined())
312
+ }
313
+
314
+ /* ------------------------------------------------------------------------ */
315
+
316
+ /**
317
+ * Expects the value to be a `number` within the specified range where the
318
+ * minimum and maximum values are inclusive.
319
+ *
320
+ * Negation: {@link NegativeMatchers.toBeWithinRange `not.toBeWithinRange(...)`}
321
+ */
322
+ toBeWithinRange(min: number, max: number): Matchers<number>
323
+
324
+ /**
325
+ * Expects the value to be a `bigint` within the specified range where the
326
+ * minimum and maximum values are inclusive.
327
+ *
328
+ * Negation: {@link NegativeMatchers.toBeWithinRange `not.toBeWithinRange(...)`}
329
+ */
330
+ toBeWithinRange(min: bigint, max: bigint): Matchers<bigint>
331
+
332
+ /**
333
+ * Expects the value to be a `number` or `bigint` within the specified range
334
+ * where minimum and maximum values are inclusive.
335
+ *
336
+ * Negation: {@link NegativeMatchers.toBeWithinRange `not.toBeWithinRange(...)`}
337
+ */
338
+ toBeWithinRange( min: number | bigint, max: number | bigint): Matchers {
339
+ return this._push((e) => e.toBeWithinRange(min as number, max as number))
340
+ }
341
+
342
+ /* ------------------------------------------------------------------------ */
343
+
344
+ /**
345
+ * Expects the value to be _deep equal to_ the specified expected one.
346
+ *
347
+ * Negation: {@link NegativeMatchers.toEqual `not.toEqual(...)`}
348
+ */
349
+ toEqual<Type>(expected: Type): Matchers<InferMatchers<Type>> {
350
+ return this._push((e) => e.toEqual(expected))
351
+ }
352
+
353
+ /* ------------------------------------------------------------------------ */
354
+
355
+ /**
356
+ * Expects the value to have a `number` _property_ `length` with the specified
357
+ * expected value.
358
+ *
359
+ * Negation: {@link NegativeMatchers.toHaveLength `not.toHaveLength(...)`}
360
+ */
361
+ toHaveLength(length: number): Matchers<T & { length: number }> {
362
+ return this._push((e) => e.toHaveLength(length))
363
+ }
364
+
365
+ /* ------------------------------------------------------------------------ */
366
+
367
+ /**
368
+ * Expects the value to have the specified _property_ and (if specified)
369
+ * further asserts its value with an {@link AssertionFunction}.
370
+ *
371
+ * Negation: {@link NegativeMatchers.toHaveProperty `not.toHaveProperty(...)`}
372
+ */
373
+ toHaveProperty<
374
+ Prop extends string | number | symbol,
375
+ Assert extends AssertionFunction,
376
+ >(
377
+ property: Prop,
378
+ assertion?: Assert,
379
+ ): Matchers<T & { [keyt in Prop] : AssertedType<unknown, Assert> }> {
380
+ return this._push((e) => e.toHaveProperty(property, assertion))
381
+ }
382
+
383
+ /* ------------------------------------------------------------------------ */
384
+
385
+ /**
386
+ * Expects the value to have a `number` _property_ `size` with the specified
387
+ * expected value.
388
+ *
389
+ * Negation: {@link NegativeMatchers.toHaveSize `not.toHaveSize(...)`}
390
+ */
391
+ toHaveSize(size: number): Matchers<T & { size: number }> {
392
+ return this._push((e) => e.toHaveSize(size))
393
+ }
394
+
395
+ /* ------------------------------------------------------------------------ */
396
+
397
+ /**
398
+ * Expect the value to include _all_ properties from the specified _object_.
399
+ *
400
+ * If the object being expected is a {@link Map}, the properties specified
401
+ * here will be treated as _mappings_ for said {@link Map}.
402
+ *
403
+ * Negation: {@link NegativeMatchers.toInclude `not.toInclude(...)`}
404
+ */
405
+ toInclude<P extends Record<string, any>>(properties: P): Matchers<T>
406
+
407
+ /**
408
+ * Expect the value to include _all_ mappings from the specified {@link Map}.
409
+ *
410
+ * Negation: {@link NegativeMatchers.toInclude `not.toInclude(...)`}
411
+ */
412
+ toInclude(mappings: Map<any, any>): Matchers<T>
413
+
414
+ /**
415
+ * Expect the value to be an {@link Iterable} object includind _all_ values
416
+ * from the specified {@link Set}, in any order.
417
+ *
418
+ * Negation: {@link NegativeMatchers.toInclude `not.toInclude(...)`}
419
+ */
420
+ toInclude(entries: Set<any>): Matchers<T>
421
+
422
+ /**
423
+ * Expect the value to be an {@link Iterable} object includind _all_ values
424
+ * from the specified _array_, in any order.
425
+ *
426
+ * Negation: {@link NegativeMatchers.toInclude `not.toInclude(...)`}
427
+ */
428
+ toInclude(values: any[]): Matchers<T>
429
+
430
+ toInclude(
431
+ contents: Record<string, any> | Map<any, any> | Set<any> | any[],
432
+ ): Matchers {
433
+ return this._push((e) => e.toInclude(contents))
434
+ }
435
+
436
+ /* ------------------------------------------------------------------------ */
437
+
438
+ /**
439
+ * Expects the value to be a `string` _matching_ the specified sub-`string`
440
+ * or {@link RegExp}.
441
+ *
442
+ * Negation: {@link NegativeMatchers.toMatch `not.toMatch(...)`}
443
+ */
444
+ toMatch<Matcher extends string | RegExp>(
445
+ matcher: Matcher,
446
+ ): Matchers<string> {
447
+ return this._push((e) => e.toMatch(matcher))
448
+ }
449
+
450
+ /* ------------------------------------------------------------------------ */
451
+
452
+ /**
453
+ * Expect the value to be an {@link Iterable} object includind _all_ values
454
+ * (and only those values) from the specified _array_, in any order.
455
+ */
456
+ toMatchContents(contents: any[]): Matchers<T>
457
+
458
+ /**
459
+ * Expect the value to be an {@link Iterable} object includind _all_ values
460
+ * (and only those values) from the specified {@link Set}, in any order.
461
+ */
462
+ toMatchContents(contents: Set<any>): Matchers<T>
463
+
464
+ toMatchContents(contents: any[] | Set<any>): Matchers {
465
+ return this._push((e) => e.toMatchContents(contents))
466
+ }
467
+
468
+ /* ------------------------------------------------------------------------ */
469
+
470
+ /**
471
+ * Expects the value to be _strictly equal to_ the specified expected one.
472
+ *
473
+ * Negation: {@link NegativeMatchers.toStrictlyEqual `not.toStrictlyEqual(...)`}
474
+ */
475
+ toStrictlyEqual<Type>(expected: Type): Matchers<Type> {
476
+ return this._push((e) => e.toStrictlyEqual(expected))
477
+ }
478
+ }
479
+
480
+ /* ========================================================================== *
481
+ * NEGATIVE MATCHERS *
482
+ * ========================================================================== */
483
+
484
+ export class NegativeMatchers<T = unknown> {
485
+ constructor(
486
+ private readonly _instance: Matchers<T>,
487
+ private readonly _matchers: Matcher[],
488
+ ) {}
489
+
490
+ private _push(matcher: NegativeMatcher): Matchers<any> {
491
+ this._matchers.push((expectations) => matcher(expectations.not))
492
+ return this._instance
493
+ }
494
+
495
+ /* ------------------------------------------------------------------------ */
496
+
497
+ /**
498
+ * Expects the value _**NOT**_ to be of the specified _extended_
499
+ * {@link TypeName type}.
500
+ *
501
+ * Negates: {@link Matchers.toBeA `toBeA(...)`}
502
+ */
503
+ toBeA(type: TypeName): Matchers<T> {
504
+ return this._push((e) => e.toBeA(type))
505
+ }
506
+
507
+ /* ------------------------------------------------------------------------ */
508
+
509
+ /**
510
+ * Expects the value to be a `number` _**OUTSIDE**_ of the given +/- _delta_
511
+ * range of the specified expected value.
512
+ *
513
+ * Negates: {@link Matchers.toBeCloseTo `toBeCloseTo(...)`}
514
+ */
515
+ toBeCloseTo(value: number, delta: number): Matchers<number>
516
+
517
+ /**
518
+ * Expects the value to be a `bigint` _**OUTSIDE**_ of the given +/- _delta_
519
+ * range of the specified expected value.
520
+ *
521
+ * Negates: {@link Matchers.toBeCloseTo `toBeCloseTo(...)`}
522
+ */
523
+ toBeCloseTo(value: bigint, delta: bigint): Matchers<bigint>
524
+
525
+ toBeCloseTo(value: number | bigint, delta: number | bigint): Matchers {
526
+ return this._push((e) => e.toBeCloseTo(value as number, delta as number))
527
+ }
528
+
529
+ /* ------------------------------------------------------------------------ */
530
+
531
+ /**
532
+ * Expects the value to be either `null` or `undefined`.
533
+ *
534
+ * Negates: {@link Matchers.toBeDefined `toBeDefined()`}
535
+ */
536
+ toBeDefined(): Matchers<null | undefined> {
537
+ return this._push((e) => e.toBeDefined())
538
+ }
539
+
540
+ /* ------------------------------------------------------------------------ */
541
+
542
+ /**
543
+ * Expects the value _**NOT**_ to be an instance of the specified
544
+ * {@link Constructor}.
545
+ *
546
+ * Negates: {@link Matchers.toBeInstanceOf `toBeInstanceOf(...)`}
547
+ */
548
+ toBeInstanceOf(constructor: Constructor): Matchers<T> {
549
+ return this._push((e) => e.toBeInstanceOf(constructor))
550
+ }
551
+
552
+ /* ------------------------------------------------------------------------ */
553
+
554
+ /**
555
+ * Expects the value _**NOT**_ to be `NaN`.
556
+ *
557
+ * Negates: {@link Matchers.toBeNaN `toBeNaN()`}
558
+ */
559
+ toBeNaN(): Matchers<number> {
560
+ return this._push((e) => e.toBeNaN())
561
+ }
562
+
563
+ /* ------------------------------------------------------------------------ */
564
+
565
+ /**
566
+ * Expects the value to be a `number` _**OUTSIDE**_ of the specified range
567
+ * where minimum and maximum values are inclusive.
568
+ *
569
+ * Negates: {@link Matchers.toBeWithinRange `toBeWithinRange(...)`}
570
+ */
571
+ toBeWithinRange(min: number, max: number): Matchers<number>
572
+
573
+ /**
574
+ * Expects the value to be a `bigint` _**OUTSIDE**_ of the specified range
575
+ * where minimum and maximum values are inclusive.
576
+ *
577
+ * Negates: {@link Matchers.toBeWithinRange `toBeWithinRange(...)`}
578
+ */
579
+ toBeWithinRange(min: bigint, max: bigint): Matchers<bigint>
580
+
581
+ toBeWithinRange(min: number | bigint, max: number | bigint): Matchers {
582
+ return this._push((e) => e.toBeWithinRange(min as number, max as number))
583
+ }
584
+
585
+ /* ------------------------------------------------------------------------ */
586
+
587
+ /**
588
+ * Expects the value _**NOT**_ to be _deep equal to_ the specified expected
589
+ * one.
590
+ *
591
+ * Negates: {@link Matchers.toEqual `toEqual(...)`}
592
+ */
593
+ toEqual(expected: any): Matchers<T> {
594
+ return this._push((e) => e.toEqual(expected))
595
+ }
596
+
597
+ /* ------------------------------------------------------------------------ */
598
+
599
+ /**
600
+ * Expects the value to have a `number` _property_ `length` _different_ from
601
+ * the specified expected value.
602
+ *
603
+ * Negates: {@link Matchers.toHaveLength `toHaveLength(...)`}
604
+ */
605
+ toHaveLength(length: number): Matchers<T & { length: number }> {
606
+ return this._push((e) => e.toHaveLength(length))
607
+ }
608
+
609
+ /* ------------------------------------------------------------------------ */
610
+
611
+ /**
612
+ * Expects the value _**NOT**_ to have the specified _property_.
613
+ *
614
+ * Negates: {@link Matchers.toHaveProperty `toHaveProperty(...)`}
615
+ */
616
+ toHaveProperty(property: string | number | symbol): Matchers<T> {
617
+ return this._push((e) => e.toHaveProperty(property))
618
+ }
619
+
620
+ /* ------------------------------------------------------------------------ */
621
+
622
+ /**
623
+ * Expects the value to have a `number` _property_ `size` _different_ from
624
+ * the specified expected value.
625
+ *
626
+ * Negates: {@link Matchers.toHaveSize `toHaveSize(...)`}
627
+ */
628
+ toHaveSize(size: number): Matchers<T & { size: number }> {
629
+ return this._push((e) => e.toHaveSize(size))
630
+ }
631
+
632
+ /* ------------------------------------------------------------------------ */
633
+
634
+ /**
635
+ * Expect the value to include _none_ of the properties from the specified
636
+ * _object_.
637
+ *
638
+ * If the object being expected is a {@link Map}, the properties specified
639
+ * here will be treated as _mappings_ for said {@link Map}.
640
+ *
641
+ * Negates: {@link Matchers.toInclude `toInclude(...)`}
642
+ */
643
+ toInclude<P extends Record<string, any>>(properties: P): Matchers<T>
644
+
645
+ /**
646
+ * Expect the value to include _none_ of the mappings from the specified
647
+ * {@link Map}.
648
+ *
649
+ * Negates: {@link Matchers.toInclude `toInclude(...)`}
650
+ */
651
+ toInclude(mappings: Map<any, any>): Matchers<T>
652
+
653
+ /**
654
+ * Expect the value to be an {@link Iterable} object includind _none_ of the
655
+ * values from the specified {@link Set}.
656
+ *
657
+ * Negates: {@link Matchers.toInclude `toInclude(...)`}
658
+ */
659
+ toInclude(entries: Set<any>): Matchers<T>
660
+
661
+ /**
662
+ * Expect the value to be an {@link Iterable} object includind _none_ of the
663
+ * values from the specified _array_.
664
+ *
665
+ * Negates: {@link Matchers.toInclude `toInclude(...)`}
666
+ */
667
+ toInclude(values: any[]): Matchers<T>
668
+
669
+ toInclude(
670
+ contents: Record<string, any> | Map<any, any> | Set<any> | any[],
671
+ ): Matchers {
672
+ return this._push((e) => e.toInclude(contents))
673
+ }
674
+
675
+ /* ------------------------------------------------------------------------ */
676
+
677
+ /**
678
+ * Expects the value to be a `string` _**NOT MATCHING**_ the specified
679
+ * sub-`string` or {@link RegExp}.
680
+ *
681
+ * Negates: {@link Matchers.toMatch `toMatch(...)`}
682
+ */
683
+ toMatch(matcher: string | RegExp): Matchers<string> {
684
+ return this._push((e) => e.toMatch(matcher))
685
+ }
686
+
687
+ /* ------------------------------------------------------------------------ */
688
+
689
+ /**
690
+ * Expects the value _**NOT**_ to be _strictly equal to_ the specified
691
+ * expected one.
692
+ *
693
+ * Negates: {@link Matchers.toStrictlyEqual `toStrictlyEqual(...)`}
694
+ */
695
+ toStrictlyEqual(expected: any): Matchers<T> {
696
+ return this._push((e) => e.toStrictlyEqual(expected))
697
+ }
698
+ }