mirror of https://github.com/nodejs/node.git
test: s/assert.notEqual()/assert.notStrictEqual()/
PR-URL: https://github.com/nodejs/node/pull/10541 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit is contained in:
parent
75ebd19d8d
commit
e5499b32cf
|
@ -33,5 +33,5 @@ fs.writeFileSync(addonDestinationPath, contents);
|
|||
|
||||
// Attempt to load at long path destination
|
||||
const addon = require(addonDestinationPath);
|
||||
assert.notEqual(addon, null);
|
||||
assert.notStrictEqual(addon, null);
|
||||
assert.strictEqual(addon.hello(), 'world');
|
||||
|
|
|
@ -6,12 +6,12 @@ const assert = require('assert');
|
|||
var oldgid = process.getgid();
|
||||
process.setgid('nobody');
|
||||
var newgid = process.getgid();
|
||||
assert.notEqual(newgid, oldgid, 'gids expected to be different');
|
||||
assert.notStrictEqual(newgid, oldgid, 'gids expected to be different');
|
||||
|
||||
var olduid = process.getuid();
|
||||
process.setuid('nobody');
|
||||
var newuid = process.getuid();
|
||||
assert.notEqual(newuid, olduid, 'uids expected to be different');
|
||||
assert.notStrictEqual(newuid, olduid, 'uids expected to be different');
|
||||
|
||||
try {
|
||||
process.setuid('nobody1234');
|
||||
|
|
|
@ -96,7 +96,7 @@ testData.forEach(function(item) {
|
|||
const actual = output.replace(/\s/g, '');
|
||||
// Assert that the input stripped of all whitespace contains the
|
||||
// expected list
|
||||
assert.notEqual(actual.indexOf(expected), -1);
|
||||
assert.notStrictEqual(actual.indexOf(expected), -1);
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const assert = require('assert');
|
||||
assert.notEqual(module, require.main, 'require.main should not == module');
|
||||
assert.notEqual(module, process.mainModule,
|
||||
'process.mainModule should not === module');
|
||||
assert.notStrictEqual(module, require.main, 'require.main should not == module');
|
||||
assert.notStrictEqual(module, process.mainModule,
|
||||
'process.mainModule should not === module');
|
||||
|
|
|
@ -6,7 +6,7 @@ const cp = require('child_process');
|
|||
// Verify that a shell is, in fact, executed
|
||||
const doesNotExist = cp.spawn('does-not-exist', {shell: true});
|
||||
|
||||
assert.notEqual(doesNotExist.spawnfile, 'does-not-exist');
|
||||
assert.notStrictEqual(doesNotExist.spawnfile, 'does-not-exist');
|
||||
doesNotExist.on('error', common.fail);
|
||||
doesNotExist.on('exit', common.mustCall((code, signal) => {
|
||||
assert.strictEqual(signal, null);
|
||||
|
|
|
@ -6,7 +6,7 @@ const cp = require('child_process');
|
|||
// Verify that a shell is, in fact, executed
|
||||
const doesNotExist = cp.spawnSync('does-not-exist', {shell: true});
|
||||
|
||||
assert.notEqual(doesNotExist.file, 'does-not-exist');
|
||||
assert.notStrictEqual(doesNotExist.file, 'does-not-exist');
|
||||
assert.strictEqual(doesNotExist.error, undefined);
|
||||
assert.strictEqual(doesNotExist.signal, null);
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
|
|||
strings.shift());
|
||||
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
|
||||
strings.shift());
|
||||
assert.notEqual(-1, strings.shift().indexOf('foo: [Object]'));
|
||||
assert.ok(strings.shift().includes('foo: [Object]'));
|
||||
assert.strictEqual(-1, strings.shift().indexOf('baz'));
|
||||
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
|
||||
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
|
||||
|
|
|
@ -47,10 +47,10 @@ function testHelper(stream, args, expectedOutput, cmd, env) {
|
|||
|
||||
function responseHandler(buffer, expectedOutput) {
|
||||
const response = buffer.toString();
|
||||
assert.notEqual(0, response.length);
|
||||
assert.notStrictEqual(response.length, 0);
|
||||
if (FIPS_ENABLED !== expectedOutput && FIPS_DISABLED !== expectedOutput) {
|
||||
// In the case of expected errors just look for a substring.
|
||||
assert.notEqual(-1, response.indexOf(expectedOutput));
|
||||
assert.ok(response.includes(expectedOutput));
|
||||
} else {
|
||||
// Normal path where we expect either FIPS enabled or disabled.
|
||||
assert.strictEqual(expectedOutput, Number(response));
|
||||
|
|
|
@ -67,8 +67,8 @@ assert.deepStrictEqual(
|
|||
// stream interface should produce the same result.
|
||||
assert.deepStrictEqual(a5, a3, 'stream interface is consistent');
|
||||
assert.deepStrictEqual(a6, a3, 'stream interface is consistent');
|
||||
assert.notEqual(a7, undefined, 'no data should return data');
|
||||
assert.notEqual(a8, undefined, 'empty string should generate data');
|
||||
assert.notStrictEqual(a7, undefined, 'no data should return data');
|
||||
assert.notStrictEqual(a8, undefined, 'empty string should generate data');
|
||||
|
||||
// Test multiple updates to same hash
|
||||
var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
|
||||
|
@ -100,7 +100,7 @@ assert.strictEqual(
|
|||
'4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' +
|
||||
'43a821af66afa9a45b6a78c712fecf0e56dc7f43aef4bcfc8eb5b4d8dca6ea5b');
|
||||
|
||||
assert.notEqual(
|
||||
assert.notStrictEqual(
|
||||
hutf8,
|
||||
crypto.createHash('sha512').update('УТФ-8 text', 'latin1').digest('hex'));
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ function runTestWithoutAbortOnUncaughtException() {
|
|||
assert(!stderr.includes(domainErrMsg), 'stderr output must not ' +
|
||||
'include domain\'s error\'s message');
|
||||
|
||||
assert.notEqual(err.code, 0,
|
||||
'child process should have exited with a non-zero ' +
|
||||
'exit code, but did not');
|
||||
assert.notStrictEqual(err.code, 0,
|
||||
'child process should have exited with a ' +
|
||||
'non-zero exit code, but did not');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,9 @@ function runTestWithAbortOnUncaughtException() {
|
|||
child_process.exec(createTestCmdLine({
|
||||
withAbortOnUncaughtException: true
|
||||
}), function onTestDone(err, stdout, stderr) {
|
||||
assert.notEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE,
|
||||
'child process should not have run its uncaughtException ' +
|
||||
'event handler');
|
||||
assert.notStrictEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE,
|
||||
'child process should not have run its ' +
|
||||
'uncaughtException event handler');
|
||||
assert(common.nodeProcessAborted(err.code, err.signal),
|
||||
'process should have aborted, but did not');
|
||||
});
|
||||
|
|
|
@ -39,8 +39,8 @@ function listener() {}
|
|||
assert.deepStrictEqual(bazListeners, [listener, listener]);
|
||||
// After calling removeAllListeners(),
|
||||
// new listeners arrays is different from the old.
|
||||
assert.notEqual(ee.listeners('bar'), barListeners);
|
||||
assert.notEqual(ee.listeners('baz'), bazListeners);
|
||||
assert.notStrictEqual(ee.listeners('bar'), barListeners);
|
||||
assert.notStrictEqual(ee.listeners('baz'), bazListeners);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ fs.access(__filename, fs.R_OK, common.mustCall((err) => {
|
|||
}));
|
||||
|
||||
fs.access(doesNotExist, common.mustCall((err) => {
|
||||
assert.notEqual(err, null, 'error should exist');
|
||||
assert.notStrictEqual(err, null, 'error should exist');
|
||||
assert.strictEqual(err.code, 'ENOENT');
|
||||
assert.strictEqual(err.path, doesNotExist);
|
||||
}));
|
||||
|
@ -85,7 +85,7 @@ fs.access(readOnlyFile, fs.W_OK, common.mustCall((err) => {
|
|||
if (hasWriteAccessForReadonlyFile) {
|
||||
assert.ifError(err);
|
||||
} else {
|
||||
assert.notEqual(err, null, 'error should exist');
|
||||
assert.notStrictEqual(err, null, 'error should exist');
|
||||
assert.strictEqual(err.path, readOnlyFile);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -54,6 +54,6 @@ const server = https.createServer(options, function(req, res) {
|
|||
process.on('exit', function() {
|
||||
assert.equal(serverRequests, TOTAL_REQS);
|
||||
assert.equal(clientSessions.length, TOTAL_REQS);
|
||||
assert.notEqual(clientSessions[0].toString('hex'),
|
||||
clientSessions[1].toString('hex'));
|
||||
assert.notStrictEqual(clientSessions[0].toString('hex'),
|
||||
clientSessions[1].toString('hex'));
|
||||
});
|
||||
|
|
|
@ -117,14 +117,14 @@ process.on('exit', function() {
|
|||
assert.strictEqual(serverRequests, 6);
|
||||
assert.strictEqual(clientSessions['first'].toString('hex'),
|
||||
clientSessions['first-reuse'].toString('hex'));
|
||||
assert.notEqual(clientSessions['first'].toString('hex'),
|
||||
clientSessions['cipher-change'].toString('hex'));
|
||||
assert.notEqual(clientSessions['first'].toString('hex'),
|
||||
clientSessions['before-drop'].toString('hex'));
|
||||
assert.notEqual(clientSessions['cipher-change'].toString('hex'),
|
||||
clientSessions['before-drop'].toString('hex'));
|
||||
assert.notEqual(clientSessions['before-drop'].toString('hex'),
|
||||
clientSessions['after-drop'].toString('hex'));
|
||||
assert.notStrictEqual(clientSessions['first'].toString('hex'),
|
||||
clientSessions['cipher-change'].toString('hex'));
|
||||
assert.notStrictEqual(clientSessions['first'].toString('hex'),
|
||||
clientSessions['before-drop'].toString('hex'));
|
||||
assert.notStrictEqual(clientSessions['cipher-change'].toString('hex'),
|
||||
clientSessions['before-drop'].toString('hex'));
|
||||
assert.notStrictEqual(clientSessions['before-drop'].toString('hex'),
|
||||
clientSessions['after-drop'].toString('hex'));
|
||||
assert.strictEqual(clientSessions['after-drop'].toString('hex'),
|
||||
clientSessions['after-drop-reuse'].toString('hex'));
|
||||
});
|
||||
|
|
|
@ -28,11 +28,11 @@ try {
|
|||
try {
|
||||
require();
|
||||
} catch (e) {
|
||||
assert.notEqual(e.toString().indexOf('missing path'), -1);
|
||||
assert.ok(e.toString().includes('missing path'));
|
||||
}
|
||||
|
||||
try {
|
||||
require({});
|
||||
} catch (e) {
|
||||
assert.notEqual(e.toString().indexOf('path must be a string'), -1);
|
||||
assert.ok(e.toString().includes('path must be a string'));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ var echoServer = net.createServer(function(connection) {
|
|||
echoServer.close();
|
||||
}, 1), common.platformTimeout(100));
|
||||
connection.setTimeout(0);
|
||||
assert.notEqual(connection.setKeepAlive, undefined);
|
||||
assert.notStrictEqual(connection.setKeepAlive, undefined);
|
||||
// send a keepalive packet after 50 ms
|
||||
connection.setKeepAlive(true, common.platformTimeout(50));
|
||||
connection.on('end', function() {
|
||||
|
|
|
@ -15,7 +15,7 @@ if (cluster.isMaster) {
|
|||
|
||||
worker2.on('message', function(port2) {
|
||||
assert.equal(port2, port2 | 0, 'second worker could not listen');
|
||||
assert.notEqual(port1, port2, 'ports should not be equal');
|
||||
assert.notStrictEqual(port1, port2, 'ports should not be equal');
|
||||
worker1.kill();
|
||||
worker2.kill();
|
||||
});
|
||||
|
|
|
@ -13,16 +13,16 @@ var remoteFamilyCandidates = ['IPv4'];
|
|||
if (common.hasIPv6) remoteFamilyCandidates.push('IPv6');
|
||||
|
||||
var server = net.createServer(common.mustCall(function(socket) {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily));
|
||||
assert.ok(socket.remotePort);
|
||||
assert.notEqual(socket.remotePort, this.address().port);
|
||||
assert.notStrictEqual(socket.remotePort, this.address().port);
|
||||
socket.on('end', function() {
|
||||
if (++conns_closed === 2) server.close();
|
||||
});
|
||||
socket.on('close', function() {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily));
|
||||
});
|
||||
socket.resume();
|
||||
}, 2));
|
||||
|
@ -31,23 +31,23 @@ server.listen(0, 'localhost', function() {
|
|||
var client = net.createConnection(this.address().port, 'localhost');
|
||||
var client2 = net.createConnection(this.address().port);
|
||||
client.on('connect', function() {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(client.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(client.remoteFamily));
|
||||
assert.strictEqual(client.remotePort, server.address().port);
|
||||
client.end();
|
||||
});
|
||||
client.on('close', function() {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(client.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(client.remoteFamily));
|
||||
});
|
||||
client2.on('connect', function() {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(client2.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily));
|
||||
assert.strictEqual(client2.remotePort, server.address().port);
|
||||
client2.end();
|
||||
});
|
||||
client2.on('close', function() {
|
||||
assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress));
|
||||
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily));
|
||||
assert.ok(remoteAddrCandidates.includes(client2.remoteAddress));
|
||||
assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -57,7 +57,7 @@ assert.throws(function() {
|
|||
|
||||
// Ensure that the return value is the expected shape.
|
||||
function validateResult(result) {
|
||||
assert.notEqual(result, null);
|
||||
assert.notStrictEqual(result, null);
|
||||
|
||||
assert(Number.isFinite(result.user));
|
||||
assert(Number.isFinite(result.system));
|
||||
|
|
|
@ -6,5 +6,5 @@ const vm = require('vm');
|
|||
assert.doesNotThrow(function() {
|
||||
var context = vm.createContext({ process: process });
|
||||
var result = vm.runInContext('process.env["PATH"]', context);
|
||||
assert.notEqual(undefined, result);
|
||||
assert.notStrictEqual(undefined, result);
|
||||
});
|
||||
|
|
|
@ -10,5 +10,5 @@ var cp = child_process.spawn(process.execPath, [
|
|||
]);
|
||||
|
||||
cp.on('exit', function(code) {
|
||||
assert.notEqual(code, 0);
|
||||
assert.notStrictEqual(code, 0);
|
||||
});
|
||||
|
|
|
@ -6,5 +6,5 @@ const assert = require('assert');
|
|||
const content = require(common.fixturesDir +
|
||||
'/json-with-directory-name-module/module-stub/one-trailing-slash/two/three.js');
|
||||
|
||||
assert.notEqual(content.rocko, 'artischocko');
|
||||
assert.notStrictEqual(content.rocko, 'artischocko');
|
||||
assert.equal(content, 'hello from module-stub!');
|
||||
|
|
|
@ -49,7 +49,7 @@ server.listen(0, function() {
|
|||
assert(gotServerEnd);
|
||||
assert(gotServerError);
|
||||
assert.equal(gotServerError.code, 'EPIPE');
|
||||
assert.notEqual(gotServerError.message, 'write after end');
|
||||
assert.notStrictEqual(gotServerError.message, 'write after end');
|
||||
console.log('ok');
|
||||
});
|
||||
|
||||
|
|
|
@ -37,5 +37,5 @@ timers.enroll(foo, 1);
|
|||
timers._unrefActive(foo);
|
||||
|
||||
setTimeout(function() {
|
||||
assert.notEqual(nbTimersFired, 2);
|
||||
assert.notStrictEqual(nbTimersFired, 2);
|
||||
}, 20);
|
||||
|
|
|
@ -25,7 +25,7 @@ var server = tls.createServer({
|
|||
});
|
||||
|
||||
c.on('error', common.mustCall(function(err) {
|
||||
assert.notEqual(err.code, 'ECONNRESET');
|
||||
assert.notStrictEqual(err.code, 'ECONNRESET');
|
||||
}));
|
||||
|
||||
c.on('close', common.mustCall(function(err) {
|
||||
|
|
|
@ -26,7 +26,7 @@ const reply = 'I AM THE WALRUS'; // something recognizable
|
|||
let response = '';
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.notEqual(response.indexOf(reply), -1);
|
||||
assert.ok(response.includes(reply));
|
||||
});
|
||||
|
||||
const server = tls.createServer(options, common.mustCall(function(conn) {
|
||||
|
|
|
@ -30,7 +30,7 @@ assert.throws(() => {
|
|||
});
|
||||
}, TypeError);
|
||||
params = new URLSearchParams('');
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
// eslint-disable-next-line no-proto
|
||||
assert.strictEqual(params.__proto__, URLSearchParams.prototype,
|
||||
'expected URLSearchParams.prototype as prototype.');
|
||||
|
@ -40,19 +40,19 @@ assert.strictEqual(params + '', '%5Bobject%20Object%5D=');
|
|||
|
||||
// URLSearchParams constructor, string.
|
||||
params = new URLSearchParams('a=b');
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.strictEqual(true, params.has('a'),
|
||||
'Search params object has name "a"');
|
||||
assert.strictEqual(false, params.has('b'),
|
||||
'Search params object has not got name "b"');
|
||||
params = new URLSearchParams('a=b&c');
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.strictEqual(true, params.has('a'),
|
||||
'Search params object has name "a"');
|
||||
assert.strictEqual(true, params.has('c'),
|
||||
'Search params object has name "c"');
|
||||
params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8');
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.strictEqual(true, params.has('a'), 'Search params object has name "a"');
|
||||
assert.strictEqual(true, params.has('a b'),
|
||||
'Search params object has name "a b"');
|
||||
|
@ -68,7 +68,7 @@ assert.strictEqual(true, params.has('møø'),
|
|||
// URLSearchParams constructor, object.
|
||||
const seed = new URLSearchParams('a=b&c=d');
|
||||
params = new URLSearchParams(seed);
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.strictEqual(params.get('a'), 'b');
|
||||
assert.strictEqual(params.get('c'), 'd');
|
||||
assert.strictEqual(false, params.has('d'));
|
||||
|
|
|
@ -24,7 +24,7 @@ assert.strictEqual(params.get('a'), '');
|
|||
|
||||
// More get() basics
|
||||
params = new URLSearchParams('first=second&third&&');
|
||||
assert.notEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
|
||||
assert.strictEqual(true, params.has('first'),
|
||||
'Search params object has name "first"');
|
||||
assert.strictEqual(params.get('first'), 'second',
|
||||
|
|
|
@ -17,5 +17,5 @@ const unzipper = new zlib.Gunzip();
|
|||
unzipper.on('close', shouldNotBeCalled);
|
||||
|
||||
const unzipped = unzipper._processChunk(zipped, zlib.constants.Z_FINISH);
|
||||
assert.notEqual(zipped.toString(), message);
|
||||
assert.notStrictEqual(zipped.toString(), message);
|
||||
assert.strictEqual(unzipped.toString(), message);
|
||||
|
|
Loading…
Reference in New Issue