assert: add internal assert.fail()

PR-URL: https://github.com/nodejs/node/pull/26047
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2019-02-12 16:44:42 -08:00 committed by Anna Henningsen
parent 1c66ad408b
commit ce65034e63
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 8 additions and 0 deletions

View File

@ -6,4 +6,10 @@ function assert(value, message) {
}
}
function fail(message) {
require('assert').fail(message);
}
assert.fail = fail;
module.exports = assert;

View File

@ -13,3 +13,5 @@ internalAssert(true, 'fhqwhgads');
assert.throws(() => { internalAssert(false); }, assert.AssertionError);
assert.throws(() => { internalAssert(false, 'fhqwhgads'); },
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });
assert.throws(() => { internalAssert.fail('fhqwhgads'); },
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });