mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
Myles Borins
parent
f2af930ebb
commit
562787efb2
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user