0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

test: remove common.expectsInternalAssertion

Remove convenience function for internal assertions. It is only used
once.

Signed-off-by: Rich Trott <rtrott@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/32057
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Rich Trott 2020-02-29 15:14:38 -08:00
parent 757e2037e7
commit 616a729b38
3 changed files with 13 additions and 20 deletions

View File

@ -547,19 +547,6 @@ function expectsError(validator, exact) {
}, exact);
}
const suffix = 'This is caused by either a bug in Node.js ' +
'or incorrect usage of Node.js internals.\n' +
'Please open an issue with this stack trace at ' +
'https://github.com/nodejs/node/issues\n';
function expectsInternalAssertion(fn, message) {
assert.throws(fn, {
message: `${message}\n${suffix}`,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION'
});
}
function skipIfInspectorDisabled() {
if (!process.features.inspector) {
skip('V8 inspector is disabled');
@ -680,7 +667,6 @@ const common = {
createZeroFilledFile,
disableCrashOnUnhandledRejection,
expectsError,
expectsInternalAssertion,
expectWarning,
getArrayBufferViews,
getBufferSources,

View File

@ -1,6 +1,6 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
require('../common');
const {
hijackStdout,
restoreStdout,
@ -50,10 +50,13 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
}
{
common.expectsInternalAssertion(
assert.throws(
() => new errors.codes.TEST_ERROR_1(),
'Code: TEST_ERROR_1; The provided arguments ' +
'length (0) does not match the required ones (1).'
{
message: /^Code: TEST_ERROR_1; The provided arguments length \(0\) does not match the required ones \(1\)\./,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION'
}
);
}

View File

@ -117,14 +117,18 @@ tmpdir.refresh();
// https://github.com/joyent/node/issues/6690
{
let oldhandle;
common.expectsInternalAssertion(
assert.throws(
() => {
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
},
'handle must be a FSEvent'
{
message: /^handle must be a FSEvent/,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION',
}
);
oldhandle.close(); // clean up
}