Commit 67ec97a
assert: implement
This adds a new functionality to the assertion module: a dedicated
check for regular expressions. So far it's possible to use
`assert.ok(regexp.test(string))`. This is not ideal though when it
comes to the error message, since it's not possible to know how
either of the input values look like. It's just known that the
assertion failed.
This allows to pass through the regular expression and the input
string. The string is then matched against the regular expression
and reports a expressive error message in case of a failure.
Backport-PR-URL: #31431
PR-URL: #30929
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>assert.match() and assert.doesNotMatch()
1 parent 5c6a6b8 commit 67ec97aCopy full SHA for 67ec97a
File tree
Expand file treeCollapse file tree
3 files changed
+220
-4
lines changedOpen diff view settings
Filter options
- doc/api
- lib
- test/parallel
Expand file treeCollapse file tree
3 files changed
+220
-4
lines changedOpen diff view settings
Collapse file
+72Lines changed: 72 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
425 | 425 | |
426 | 426 | |
427 | 427 | |
| 428 | + |
| 429 | + |
| 430 | + |
| 431 | + |
| 432 | + |
| 433 | + |
| 434 | + |
| 435 | + |
| 436 | + |
| 437 | + |
| 438 | + |
| 439 | + |
| 440 | + |
| 441 | + |
| 442 | + |
| 443 | + |
| 444 | + |
| 445 | + |
| 446 | + |
| 447 | + |
| 448 | + |
| 449 | + |
| 450 | + |
| 451 | + |
| 452 | + |
| 453 | + |
| 454 | + |
| 455 | + |
| 456 | + |
| 457 | + |
| 458 | + |
| 459 | + |
| 460 | + |
| 461 | + |
| 462 | + |
| 463 | + |
428 | 464 | |
429 | 465 | |
430 | 466 | |
| ||
728 | 764 | |
729 | 765 | |
730 | 766 | |
| 767 | + |
| 768 | + |
| 769 | + |
| 770 | + |
| 771 | + |
| 772 | + |
| 773 | + |
| 774 | + |
| 775 | + |
| 776 | + |
| 777 | + |
| 778 | + |
| 779 | + |
| 780 | + |
| 781 | + |
| 782 | + |
| 783 | + |
| 784 | + |
| 785 | + |
| 786 | + |
| 787 | + |
| 788 | + |
| 789 | + |
| 790 | + |
| 791 | + |
| 792 | + |
| 793 | + |
| 794 | + |
| 795 | + |
| 796 | + |
| 797 | + |
| 798 | + |
| 799 | + |
| 800 | + |
| 801 | + |
| 802 | + |
731 | 803 | |
732 | 804 | |
733 | 805 | |
|
Collapse file
+48-4Lines changed: 48 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
27 | 27 | |
28 | 28 | |
29 | 29 | |
| 30 | + |
30 | 31 | |
31 | 32 | |
32 | 33 | |
| ||
533 | 534 | |
534 | 535 | |
535 | 536 | |
536 | | - |
| 537 | + |
537 | 538 | |
538 | 539 | |
539 | 540 | |
| ||
579 | 580 | |
580 | 581 | |
581 | 582 | |
582 | | - |
| 583 | + |
583 | 584 | |
584 | 585 | |
585 | 586 | |
| ||
614 | 615 | |
615 | 616 | |
616 | 617 | |
617 | | - |
| 618 | + |
618 | 619 | |
619 | 620 | |
620 | 621 | |
| ||
751 | 752 | |
752 | 753 | |
753 | 754 | |
754 | | - |
| 755 | + |
755 | 756 | |
756 | 757 | |
757 | 758 | |
| ||
856 | 857 | |
857 | 858 | |
858 | 859 | |
| 860 | + |
| 861 | + |
| 862 | + |
| 863 | + |
| 864 | + |
| 865 | + |
| 866 | + |
| 867 | + |
| 868 | + |
| 869 | + |
| 870 | + |
| 871 | + |
| 872 | + |
| 873 | + |
| 874 | + |
| 875 | + |
| 876 | + |
| 877 | + |
| 878 | + |
| 879 | + |
| 880 | + |
| 881 | + |
| 882 | + |
| 883 | + |
| 884 | + |
| 885 | + |
| 886 | + |
| 887 | + |
| 888 | + |
| 889 | + |
| 890 | + |
| 891 | + |
| 892 | + |
| 893 | + |
| 894 | + |
| 895 | + |
| 896 | + |
| 897 | + |
| 898 | + |
| 899 | + |
| 900 | + |
| 901 | + |
| 902 | + |
859 | 903 | |
860 | 904 | |
861 | 905 | |
|
Collapse file
test/parallel/test-assert.js
Copy file name to clipboardExpand all lines: test/parallel/test-assert.js+100Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1301 | 1301 | |
1302 | 1302 | |
1303 | 1303 | |
| 1304 | + |
| 1305 | + |
| 1306 | + |
| 1307 | + |
| 1308 | + |
| 1309 | + |
| 1310 | + |
| 1311 | + |
| 1312 | + |
| 1313 | + |
| 1314 | + |
| 1315 | + |
| 1316 | + |
| 1317 | + |
| 1318 | + |
| 1319 | + |
| 1320 | + |
| 1321 | + |
| 1322 | + |
| 1323 | + |
| 1324 | + |
| 1325 | + |
| 1326 | + |
| 1327 | + |
| 1328 | + |
| 1329 | + |
| 1330 | + |
| 1331 | + |
| 1332 | + |
| 1333 | + |
| 1334 | + |
| 1335 | + |
| 1336 | + |
| 1337 | + |
| 1338 | + |
| 1339 | + |
| 1340 | + |
| 1341 | + |
| 1342 | + |
| 1343 | + |
| 1344 | + |
| 1345 | + |
| 1346 | + |
| 1347 | + |
| 1348 | + |
| 1349 | + |
| 1350 | + |
| 1351 | + |
| 1352 | + |
| 1353 | + |
| 1354 | + |
| 1355 | + |
| 1356 | + |
| 1357 | + |
| 1358 | + |
| 1359 | + |
| 1360 | + |
| 1361 | + |
| 1362 | + |
| 1363 | + |
| 1364 | + |
| 1365 | + |
| 1366 | + |
| 1367 | + |
| 1368 | + |
| 1369 | + |
| 1370 | + |
| 1371 | + |
| 1372 | + |
| 1373 | + |
| 1374 | + |
| 1375 | + |
| 1376 | + |
| 1377 | + |
| 1378 | + |
| 1379 | + |
| 1380 | + |
| 1381 | + |
| 1382 | + |
| 1383 | + |
| 1384 | + |
| 1385 | + |
| 1386 | + |
| 1387 | + |
| 1388 | + |
| 1389 | + |
| 1390 | + |
| 1391 | + |
| 1392 | + |
| 1393 | + |
| 1394 | + |
| 1395 | + |
| 1396 | + |
| 1397 | + |
| 1398 | + |
| 1399 | + |
| 1400 | + |
| 1401 | + |
| 1402 | + |
| 1403 | + |
0 commit comments