@@ -87,6 +87,12 @@ class Assert {
87
87
this . AssertionError = AssertionError ;
88
88
}
89
89
90
+ #innerFail( obj ) {
91
+ if ( obj . message instanceof Error ) throw obj . message ;
92
+
93
+ throw new AssertionError ( obj ) ;
94
+ }
95
+
90
96
#internalMatch( string , regexp , message , fn ) {
91
97
if ( ! isRegExp ( regexp ) ) {
92
98
throw new ERR_INVALID_ARG_TYPE (
@@ -140,7 +146,7 @@ class Assert {
140
146
err . operator = fn . name ;
141
147
throw err ;
142
148
}
143
- innerFail ( {
149
+ this . # innerFail( {
144
150
actual,
145
151
expected,
146
152
message,
@@ -293,7 +299,7 @@ class Assert {
293
299
}
294
300
details += message ? `: ${ message } ` : '.' ;
295
301
const fnType = stackStartFn === Assert . prototype . rejects ? 'rejection' : 'exception' ;
296
- innerFail ( {
302
+ this . # innerFail( {
297
303
actual : undefined ,
298
304
expected : error ,
299
305
operator : stackStartFn . name ,
@@ -321,7 +327,7 @@ class Assert {
321
327
const details = message ? `: ${ message } ` : '.' ;
322
328
const fnType = stackStartFn === Assert . prototype . doesNotReject ?
323
329
'rejection' : 'exception' ;
324
- innerFail ( {
330
+ this . # innerFail( {
325
331
actual,
326
332
expected : error ,
327
333
operator : stackStartFn . name ,
@@ -428,7 +434,7 @@ class Assert {
428
434
}
429
435
// eslint-disable-next-line eqeqeq
430
436
if ( actual != expected && ( ! NumberIsNaN ( actual ) || ! NumberIsNaN ( expected ) ) ) {
431
- innerFail ( {
437
+ this . # innerFail( {
432
438
actual,
433
439
expected,
434
440
message,
@@ -452,7 +458,7 @@ class Assert {
452
458
}
453
459
// eslint-disable-next-line eqeqeq
454
460
if ( actual == expected || ( NumberIsNaN ( actual ) && NumberIsNaN ( expected ) ) ) {
455
- innerFail ( {
461
+ this . # innerFail( {
456
462
actual,
457
463
expected,
458
464
message,
@@ -475,7 +481,7 @@ class Assert {
475
481
}
476
482
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
477
483
if ( ! isDeepEqual ( actual , expected ) ) {
478
- innerFail ( {
484
+ this . # innerFail( {
479
485
actual,
480
486
expected,
481
487
message,
@@ -498,7 +504,7 @@ class Assert {
498
504
}
499
505
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
500
506
if ( isDeepEqual ( actual , expected ) ) {
501
- innerFail ( {
507
+ this . # innerFail( {
502
508
actual,
503
509
expected,
504
510
message,
@@ -522,7 +528,7 @@ class Assert {
522
528
}
523
529
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
524
530
if ( ! isDeepStrictEqual ( actual , expected ) ) {
525
- innerFail ( {
531
+ this . # innerFail( {
526
532
actual,
527
533
expected,
528
534
message,
@@ -546,7 +552,7 @@ class Assert {
546
552
}
547
553
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
548
554
if ( isDeepStrictEqual ( actual , expected ) ) {
549
- innerFail ( {
555
+ this . # innerFail( {
550
556
actual,
551
557
expected,
552
558
message,
@@ -568,7 +574,7 @@ class Assert {
568
574
throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
569
575
}
570
576
if ( ! ObjectIs ( actual , expected ) ) {
571
- innerFail ( {
577
+ this . # innerFail( {
572
578
actual,
573
579
expected,
574
580
message,
@@ -590,7 +596,7 @@ class Assert {
590
596
throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
591
597
}
592
598
if ( ObjectIs ( actual , expected ) ) {
593
- innerFail ( {
599
+ this . # innerFail( {
594
600
actual,
595
601
expected,
596
602
message,
@@ -617,7 +623,7 @@ class Assert {
617
623
}
618
624
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
619
625
if ( ! isPartialStrictEqual ( actual , expected ) ) {
620
- innerFail ( {
626
+ this . # innerFail( {
621
627
actual,
622
628
expected,
623
629
message,
@@ -775,13 +781,6 @@ assert.ok = ok;
775
781
// may be undefined if not provided. All assertion methods provide
776
782
// both the actual and expected values to the assertion error for
777
783
// display purposes.
778
-
779
- function innerFail ( obj ) {
780
- if ( obj . message instanceof Error ) throw obj . message ;
781
-
782
- throw new AssertionError ( obj ) ;
783
- }
784
-
785
784
class Comparison {
786
785
constructor ( obj , keys , actual ) {
787
786
for ( const key of keys ) {
0 commit comments