GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — assert: fix .throws operator · nodejs/node@84948cf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • assert.js
  • test/parallel
    • test-assert.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/assert.js‎

Copy file name to clipboardExpand all lines: lib/assert.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,18 @@ function innerThrows(shouldThrow, block, expected, message) {
643643
details += ` (${expected.name})`;
644644
}
645645
details += message ? `: ${message}` : '.';
646-
fail(actual, expected, `Missing expected exception${details}`, fail);
646+
fail(actual, expected, `Missing expected exception${details}`, 'throws');
647647
}
648648
if (expected && expectedException(actual, expected) === false) {
649649
throw actual;
650650
}
651651
} else if (actual !== undefined) {
652652
if (!expected || expectedException(actual, expected)) {
653653
details = message ? `: ${message}` : '.';
654-
fail(actual, expected, `Got unwanted exception${details}`, fail);
654+
fail(actual,
655+
expected,
656+
`Got unwanted exception${details}`,
657+
'doesNotThrow');
655658
}
656659
throw actual;
657660
}
Collapse file

‎test/parallel/test-assert.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-assert.js
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,15 @@ assert.throws(() => { assert.ifError(new Error('test error')); },
463463
assert.doesNotThrow(() => { assert.ifError(null); });
464464
assert.doesNotThrow(() => { assert.ifError(); });
465465

466-
assert.throws(() => {
467-
assert.doesNotThrow(makeBlock(thrower, Error), 'user message');
468-
}, /Got unwanted exception: user message/,
469-
'a.doesNotThrow ignores user message');
466+
common.expectsError(
467+
() => assert.doesNotThrow(makeBlock(thrower, Error), 'user message'),
468+
{
469+
type: a.AssertionError,
470+
code: 'ERR_ASSERTION',
471+
operator: 'doesNotThrow',
472+
message: 'Got unwanted exception: user message\n[object Object]'
473+
}
474+
);
470475

471476
// make sure that validating using constructor really works
472477
{
@@ -525,7 +530,8 @@ a.throws(makeBlock(thrower, TypeError), (err) => {
525530
() => { a.throws((noop)); },
526531
common.expectsError({
527532
code: 'ERR_ASSERTION',
528-
message: /^Missing expected exception\.$/
533+
message: /^Missing expected exception\.$/,
534+
operator: 'throws'
529535
}));
530536

531537
assert.throws(

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.