| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 24aeca7 commit 1e5c7e3
1 file 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: /Got unwanted exception: user message\n\[object Object\]/ | ||
| 488 | - })(e); | ||
| 479 | + common.expectsError( | ||
| 480 | + () => assert.doesNotThrow(makeBlock(thrower, Error), 'user message'), | ||
| 481 | + { | ||
| 482 | + code: 'ERR_ASSERTION', | ||
| 483 | + message: /Got unwanted exception: user message\n\[object Object\]/ | ||
| 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: /Got unwanted exception\.\n\[object Object\]/ | ||
| 502 | - })(e); | ||
| 487 | + common.expectsError( | ||
| 488 | + () => assert.doesNotThrow(makeBlock(thrower, Error)), | ||
| 489 | + { | ||
| 490 | + code: 'ERR_ASSERTION', | ||
| 491 | + message: /Got unwanted exception\.\n\[object Object\]/ | ||
| 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'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments