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: nodejs#17582

PR-URL: nodejs#17903
Refs: nodejs#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 Mar 8, 2018
1 parent 7f558d5 commit fe9f098
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 @@ -319,7 +319,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 fe9f098

Please sign in to comment.