Commit ef8f147
committed
assert: improve regular expression validation
This makes sure `assert.throws()` and `assert.rejects()` result in
an easy to understand error message instead of rethrowing the actual
error. This should significantly improve the debugging experience in
case people use an regular expression to validate their errors.
This also adds support for primitive errors that would have caused
runtime errors using the mentioned functions. The input is now
stringified before it's passed to the RegExp to circumvent that.
As drive-by change this also adds some further comments and renames
a variable for clarity.
PR-URL: #27781
Reviewed-By: Rich Trott <rtrott@gmail.com>1 parent 8157a50 commit ef8f147
2 files changed
+75
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
553 | 553 | | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
561 | 568 | | |
562 | 569 | | |
563 | 570 | | |
564 | 571 | | |
565 | 572 | | |
566 | 573 | | |
567 | 574 | | |
568 | | - | |
| 575 | + | |
569 | 576 | | |
570 | 577 | | |
571 | 578 | | |
572 | 579 | | |
573 | 580 | | |
574 | 581 | | |
575 | 582 | | |
| 583 | + | |
576 | 584 | | |
577 | 585 | | |
578 | 586 | | |
| |||
589 | 597 | | |
590 | 598 | | |
591 | 599 | | |
592 | | - | |
| 600 | + | |
593 | 601 | | |
594 | | - | |
| 602 | + | |
595 | 603 | | |
| 604 | + | |
596 | 605 | | |
| 606 | + | |
597 | 607 | | |
598 | | - | |
| 608 | + | |
599 | 609 | | |
600 | 610 | | |
601 | | - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
602 | 618 | | |
603 | | - | |
604 | 619 | | |
605 | 620 | | |
606 | 621 | | |
| |||
695 | 710 | | |
696 | 711 | | |
697 | 712 | | |
698 | | - | |
699 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
700 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
701 | 738 | | |
702 | 739 | | |
703 | 740 | | |
| |||
709 | 746 | | |
710 | 747 | | |
711 | 748 | | |
712 | | - | |
| 749 | + | |
713 | 750 | | |
714 | 751 | | |
715 | 752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
186 | 206 | | |
187 | 207 | | |
188 | 208 | | |
| |||
0 commit comments