assert: fix strict regression
Using `assert()` or `assert.ok()` resulted in a error since a refactoring. Refs: https://github.com/nodejs/node/pull/17582 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:
parent
968e20c7e5
commit
8578fe22a9
@ -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,
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user