File tree 1 file changed +18
-36
lines changed
1 file changed +18
-36
lines changed Original file line number Diff line number Diff line change @@ -476,33 +476,21 @@ common.expectsError(
476
476
}
477
477
) ;
478
478
479
- {
480
- let threw = false ;
481
- try {
482
- assert . doesNotThrow ( makeBlock ( thrower , Error ) , 'user message' ) ;
483
- } catch ( e ) {
484
- threw = true ;
485
- common . expectsError ( {
486
- code : 'ERR_ASSERTION' ,
487
- message : / G o t u n w a n t e d e x c e p t i o n : u s e r m e s s a g e \n \[ o b j e c t O b j e c t \] /
488
- } ) ( e ) ;
479
+ common . expectsError (
480
+ ( ) => assert . doesNotThrow ( makeBlock ( thrower , Error ) , 'user message' ) ,
481
+ {
482
+ code : 'ERR_ASSERTION' ,
483
+ message : / G o t u n w a n t e d e x c e p t i o n : u s e r m e s s a g e \n \[ o b j e c t O b j e c t \] /
489
484
}
490
- assert . ok ( threw ) ;
491
- }
485
+ ) ;
492
486
493
- {
494
- let threw = false ;
495
- try {
496
- assert . doesNotThrow ( makeBlock ( thrower , Error ) ) ;
497
- } catch ( e ) {
498
- threw = true ;
499
- common . expectsError ( {
500
- code : 'ERR_ASSERTION' ,
501
- message : / G o t u n w a n t e d e x c e p t i o n \. \n \[ o b j e c t O b j e c t \] /
502
- } ) ( e ) ;
487
+ common . expectsError (
488
+ ( ) => assert . doesNotThrow ( makeBlock ( thrower , Error ) ) ,
489
+ {
490
+ code : 'ERR_ASSERTION' ,
491
+ message : / G o t u n w a n t e d e x c e p t i o n \. \n \[ o b j e c t O b j e c t \] /
503
492
}
504
- assert . ok ( threw ) ;
505
- }
493
+ ) ;
506
494
507
495
// make sure that validating using constructor really works
508
496
{
@@ -691,21 +679,15 @@ try {
691
679
}
692
680
693
681
const testBlockTypeError = ( method , block ) => {
694
- let threw = true ;
695
-
696
- try {
697
- method ( block ) ;
698
- threw = false ;
699
- } catch ( e ) {
700
- common . expectsError ( {
682
+ common . expectsError (
683
+ ( ) => method ( block ) ,
684
+ {
701
685
code : 'ERR_INVALID_ARG_TYPE' ,
702
686
type : TypeError ,
703
687
message : 'The "block" argument must be of type Function. Received ' +
704
- `type ${ typeName ( block ) } `
705
- } ) ( e ) ;
706
- }
707
-
708
- assert . ok ( threw ) ;
688
+ `type ${ typeName ( block ) } `
689
+ }
690
+ ) ;
709
691
} ;
710
692
711
693
testBlockTypeError ( assert . throws , 'string' ) ;
You can’t perform that action at this time.
0 commit comments