Skip to content

Commit

Permalink
assert: fix throws and doesNotThrow stack frames
Browse files Browse the repository at this point in the history
The stack frames from .throws and .doesNotThrow got included
even though that was not intended.

PR-URL: nodejs#17703
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Mar 8, 2018
1 parent da78022 commit 9664cc8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function innerThrows(shouldThrow, block, expected, message) {
expected,
operator: 'throws',
message: `Missing expected exception${details}`,
stackStartFn: innerThrows
stackStartFn: assert.throws
});
}
if (expected && expectedException(actual, expected) === false) {
Expand All @@ -259,7 +259,7 @@ function innerThrows(shouldThrow, block, expected, message) {
expected,
operator: 'doesNotThrow',
message: `Got unwanted exception${details}\n${actual.message}`,
stackStartFn: innerThrows
stackStartFn: assert.doesNotThrow
});
}
throw actual;
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity },
} catch (e) {
threw = true;
assert.strictEqual(e.message, 'Missing expected exception.');
assert.ok(!e.stack.includes('throws'), e.stack);
}
assert.ok(threw);
}
Expand Down Expand Up @@ -678,6 +679,7 @@ try {
threw = true;
assert.ok(e.message.includes(rangeError.message));
assert.ok(e instanceof assert.AssertionError);
assert.ok(!e.stack.includes('doesNotThrow'), e.stack);
}
assert.ok(threw);
}
Expand Down

0 comments on commit 9664cc8

Please sign in to comment.