Skip to content

Commit

Permalink
assert: fix strict regression
Browse files Browse the repository at this point in the history
Using `assert()` or `assert.ok()` resulted in a error since a
refactoring.

Refs: #17582

PR-URL: #17903
Refs: #17582
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
BridgeAR committed Dec 28, 2017
1 parent 968e20c commit 8578fe2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,15 @@ assert.ifError = function ifError(err) { if (err) throw err; };

// Expose a strict only variant of assert
function strict(value, message) {
if (!value) innerFail(value, true, message, '==', strict);
if (!value) {
innerFail({
actual: value,
expected: true,
message,
operator: '==',
stackStartFn: strict
});
}
}
assert.strict = Object.assign(strict, assert, {
equal: assert.strictEqual,
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,14 @@ common.expectsError(
assert.equal(Object.keys(assert).length, Object.keys(a).length);
/* eslint-enable no-restricted-properties */
assert(7);
common.expectsError(
() => assert(),
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'undefined == true'
}
);
}

common.expectsError(
Expand Down

0 comments on commit 8578fe2

Please sign in to comment.