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 Dec 19, 2017
1 parent 85d5885 commit d9171fe
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
Expand Up @@ -242,7 +242,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 @@ -256,7 +256,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
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 d9171fe

Please sign in to comment.