Commit bb857d9
assert: make sure throws is able to handle primitives
This fixes some possible issues with `assert.throws` and
`assert.rejects` in combination with an validation object. It will
now properly handle primitive values being thrown as error.
It also makes sure the `generatedMessage` property is properly set
if `assert.throws` or `assert.rejects` is used in combination with
an validation object and improves the error performance in such cases
by only creating the error once.
In addition it will fix detecting regular expressions from a different
context such as n-api that are passed through as validator for
`assert.throws` or `assert.rejects`. Until now those were not tested.
PR-URL: #20482
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>1 parent e93726a commit bb857d9Copy full SHA for bb857d9
File tree
Expand file treeCollapse file tree
3 files changed
+72
-7
lines changedOpen diff view settings
Filter options
- lib
- test
- message
- parallel
Expand file treeCollapse file tree
3 files changed
+72
-7
lines changedOpen diff view settings
Collapse file
+25-5Lines changed: 25 additions & 5 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
382 | 382 | |
383 | 383 | |
384 | 384 | |
385 | | - |
386 | | - |
387 | 385 | |
388 | 386 | |
389 | 387 | |
390 | 388 | |
391 | 389 | |
392 | 390 | |
393 | | - |
394 | | - |
| 391 | + |
| 392 | + |
| 393 | + |
| 394 | + |
395 | 395 | |
396 | 396 | |
397 | 397 | |
| ||
405 | 405 | |
406 | 406 | |
407 | 407 | |
408 | | - |
| 408 | + |
409 | 409 | |
410 | 410 | |
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | 414 | |
415 | 415 | |
| 416 | + |
| 417 | + |
| 418 | + |
| 419 | + |
| 420 | + |
| 421 | + |
| 422 | + |
| 423 | + |
| 424 | + |
| 425 | + |
| 426 | + |
| 427 | + |
| 428 | + |
| 429 | + |
| 430 | + |
| 431 | + |
| 432 | + |
| 433 | + |
| 434 | + |
| 435 | + |
416 | 436 | |
417 | 437 | |
418 | 438 | |
|
Collapse file
test/message/assert_throws_stack.out
Copy file name to clipboardExpand all lines: test/message/assert_throws_stack.out+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | | - |
3 | | - |
| 2 | + |
| 3 | + |
4 | 4 | |
5 | 5 | |
6 | 6 | |
|
Collapse file
test/parallel/test-assert.js
Copy file name to clipboardExpand all lines: test/parallel/test-assert.js+45Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
740 | 740 | |
741 | 741 | |
742 | 742 | |
| 743 | + |
743 | 744 | |
| 745 | + |
744 | 746 | |
745 | 747 | |
746 | 748 | |
| ||
849 | 851 | |
850 | 852 | |
851 | 853 | |
| 854 | + |
852 | 855 | |
853 | 856 | |
854 | 857 | |
| ||
940 | 943 | |
941 | 944 | |
942 | 945 | |
| 946 | + |
| 947 | + |
| 948 | + |
| 949 | + |
| 950 | + |
| 951 | + |
| 952 | + |
| 953 | + |
| 954 | + |
| 955 | + |
| 956 | + |
| 957 | + |
| 958 | + |
| 959 | + |
| 960 | + |
| 961 | + |
| 962 | + |
| 963 | + |
| 964 | + |
| 965 | + |
| 966 | + |
| 967 | + |
| 968 | + |
| 969 | + |
| 970 | + |
| 971 | + |
| 972 | + |
| 973 | + |
| 974 | + |
| 975 | + |
| 976 | + |
| 977 | + |
| 978 | + |
| 979 | + |
| 980 | + |
| 981 | + |
| 982 | + |
| 983 | + |
| 984 | + |
| 985 | + |
| 986 | + |
| 987 | + |
0 commit comments