assert: fix strict regression

Using `assert()` or `assert.ok()` resulted in a error since a
refactoring.

Refs: https://github.com/nodejs/node/pull/17582

Backport-PR-URL: https://github.com/nodejs/node/pull/23223
PR-URL: https://github.com/nodejs/node/pull/17903
Refs: https://github.com/nodejs/node/pull/17582
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater
2017-12-28 18:58:08 +01:00
committed by Myles Borins
parent f2af930ebb
commit 562787efb2
2 changed files with 17 additions and 1 deletions

View File

@@ -783,7 +783,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,

View File

@@ -711,6 +711,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(