Skip to content

Commit 5013022

Browse files
cjihrigitaloacasas
authored andcommitted
test: s/assert.notEqual()/assert.notStrictEqual()/
PR-URL: #10541 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]>
1 parent 44174a5 commit 5013022

29 files changed

+64
-64
lines changed

test/addons/load-long-path/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ fs.writeFileSync(addonDestinationPath, contents);
3333

3434
// Attempt to load at long path destination
3535
const addon = require(addonDestinationPath);
36-
assert.notEqual(addon, null);
36+
assert.notStrictEqual(addon, null);
3737
assert.strictEqual(addon.hello(), 'world');

test/disabled/test-setuidgid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ const assert = require('assert');
66
var oldgid = process.getgid();
77
process.setgid('nobody');
88
var newgid = process.getgid();
9-
assert.notEqual(newgid, oldgid, 'gids expected to be different');
9+
assert.notStrictEqual(newgid, oldgid, 'gids expected to be different');
1010

1111
var olduid = process.getuid();
1212
process.setuid('nobody');
1313
var newuid = process.getuid();
14-
assert.notEqual(newuid, olduid, 'uids expected to be different');
14+
assert.notStrictEqual(newuid, olduid, 'uids expected to be different');
1515

1616
try {
1717
process.setuid('nobody1234');

test/doctool/test-doctool-html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ testData.forEach((item) => {
9696
const actual = output.replace(/\s/g, '');
9797
// Assert that the input stripped of all whitespace contains the
9898
// expected list
99-
assert.notEqual(actual.indexOf(expected), -1);
99+
assert.notStrictEqual(actual.indexOf(expected), -1);
100100
}));
101101
}));
102102
}));

test/fixtures/not-main-module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const assert = require('assert');
2-
assert.notEqual(module, require.main, 'require.main should not == module');
3-
assert.notEqual(module, process.mainModule,
4-
'process.mainModule should not === module');
2+
assert.notStrictEqual(module, require.main, 'require.main should not == module');
3+
assert.notStrictEqual(module, process.mainModule,
4+
'process.mainModule should not === module');

test/parallel/test-child-process-spawn-shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const cp = require('child_process');
66
// Verify that a shell is, in fact, executed
77
const doesNotExist = cp.spawn('does-not-exist', {shell: true});
88

9-
assert.notEqual(doesNotExist.spawnfile, 'does-not-exist');
9+
assert.notStrictEqual(doesNotExist.spawnfile, 'does-not-exist');
1010
doesNotExist.on('error', common.fail);
1111
doesNotExist.on('exit', common.mustCall((code, signal) => {
1212
assert.strictEqual(signal, null);

test/parallel/test-child-process-spawnsync-shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const cp = require('child_process');
66
// Verify that a shell is, in fact, executed
77
const doesNotExist = cp.spawnSync('does-not-exist', {shell: true});
88

9-
assert.notEqual(doesNotExist.file, 'does-not-exist');
9+
assert.notStrictEqual(doesNotExist.file, 'does-not-exist');
1010
assert.strictEqual(doesNotExist.error, undefined);
1111
assert.strictEqual(doesNotExist.signal, null);
1212

test/parallel/test-console.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
115115
strings.shift());
116116
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
117117
strings.shift());
118-
assert.notEqual(-1, strings.shift().indexOf('foo: [Object]'));
118+
assert.ok(strings.shift().includes('foo: [Object]'));
119119
assert.strictEqual(-1, strings.shift().indexOf('baz'));
120120
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
121121
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));

test/parallel/test-crypto-fips.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ function testHelper(stream, args, expectedOutput, cmd, env) {
4747

4848
function responseHandler(buffer, expectedOutput) {
4949
const response = buffer.toString();
50-
assert.notEqual(0, response.length);
50+
assert.notStrictEqual(response.length, 0);
5151
if (FIPS_ENABLED !== expectedOutput && FIPS_DISABLED !== expectedOutput) {
5252
// In the case of expected errors just look for a substring.
53-
assert.notEqual(-1, response.indexOf(expectedOutput));
53+
assert.ok(response.includes(expectedOutput));
5454
} else {
5555
// Normal path where we expect either FIPS enabled or disabled.
5656
assert.strictEqual(expectedOutput, Number(response));

test/parallel/test-crypto-hash.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ assert.deepStrictEqual(
6767
// stream interface should produce the same result.
6868
assert.deepStrictEqual(a5, a3, 'stream interface is consistent');
6969
assert.deepStrictEqual(a6, a3, 'stream interface is consistent');
70-
assert.notEqual(a7, undefined, 'no data should return data');
71-
assert.notEqual(a8, undefined, 'empty string should generate data');
70+
assert.notStrictEqual(a7, undefined, 'no data should return data');
71+
assert.notStrictEqual(a8, undefined, 'empty string should generate data');
7272

7373
// Test multiple updates to same hash
7474
var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
@@ -100,7 +100,7 @@ assert.strictEqual(
100100
'4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' +
101101
'43a821af66afa9a45b6a78c712fecf0e56dc7f43aef4bcfc8eb5b4d8dca6ea5b');
102102

103-
assert.notEqual(
103+
assert.notStrictEqual(
104104
hutf8,
105105
crypto.createHash('sha512').update('УТФ-8 text', 'latin1').digest('hex'));
106106

test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ function runTestWithAbortOnUncaughtException() {
7272
child_process.exec(createTestCmdLine({
7373
withAbortOnUncaughtException: true
7474
}), function onTestDone(err, stdout, stderr) {
75-
assert.notEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE,
76-
'child process should not have run its uncaughtException ' +
77-
'event handler');
75+
assert.notStrictEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE,
76+
'child process should not have run its ' +
77+
'uncaughtException event handler');
7878
assert(common.nodeProcessAborted(err.code, err.signal),
7979
'process should have aborted, but did not');
8080
});

test/parallel/test-event-emitter-remove-all-listeners.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ function listener() {}
3939
assert.deepStrictEqual(bazListeners, [listener, listener]);
4040
// After calling removeAllListeners(),
4141
// new listeners arrays is different from the old.
42-
assert.notEqual(ee.listeners('bar'), barListeners);
43-
assert.notEqual(ee.listeners('baz'), bazListeners);
42+
assert.notStrictEqual(ee.listeners('bar'), barListeners);
43+
assert.notStrictEqual(ee.listeners('baz'), bazListeners);
4444
}
4545

4646
{

test/parallel/test-fs-access.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fs.access(__filename, fs.R_OK, common.mustCall((err) => {
7272
}));
7373

7474
fs.access(doesNotExist, common.mustCall((err) => {
75-
assert.notEqual(err, null, 'error should exist');
75+
assert.notStrictEqual(err, null, 'error should exist');
7676
assert.strictEqual(err.code, 'ENOENT');
7777
assert.strictEqual(err.path, doesNotExist);
7878
}));
@@ -85,7 +85,7 @@ fs.access(readOnlyFile, fs.W_OK, common.mustCall((err) => {
8585
if (hasWriteAccessForReadonlyFile) {
8686
assert.ifError(err);
8787
} else {
88-
assert.notEqual(err, null, 'error should exist');
88+
assert.notStrictEqual(err, null, 'error should exist');
8989
assert.strictEqual(err.path, readOnlyFile);
9090
}
9191
}));

test/parallel/test-https-agent-disable-session-reuse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ const server = https.createServer(options, function(req, res) {
5454
process.on('exit', function() {
5555
assert.equal(serverRequests, TOTAL_REQS);
5656
assert.equal(clientSessions.length, TOTAL_REQS);
57-
assert.notEqual(clientSessions[0].toString('hex'),
58-
clientSessions[1].toString('hex'));
57+
assert.notStrictEqual(clientSessions[0].toString('hex'),
58+
clientSessions[1].toString('hex'));
5959
});

test/parallel/test-https-agent-session-reuse.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ process.on('exit', function() {
117117
assert.strictEqual(serverRequests, 6);
118118
assert.strictEqual(clientSessions['first'].toString('hex'),
119119
clientSessions['first-reuse'].toString('hex'));
120-
assert.notEqual(clientSessions['first'].toString('hex'),
121-
clientSessions['cipher-change'].toString('hex'));
122-
assert.notEqual(clientSessions['first'].toString('hex'),
123-
clientSessions['before-drop'].toString('hex'));
124-
assert.notEqual(clientSessions['cipher-change'].toString('hex'),
125-
clientSessions['before-drop'].toString('hex'));
126-
assert.notEqual(clientSessions['before-drop'].toString('hex'),
127-
clientSessions['after-drop'].toString('hex'));
120+
assert.notStrictEqual(clientSessions['first'].toString('hex'),
121+
clientSessions['cipher-change'].toString('hex'));
122+
assert.notStrictEqual(clientSessions['first'].toString('hex'),
123+
clientSessions['before-drop'].toString('hex'));
124+
assert.notStrictEqual(clientSessions['cipher-change'].toString('hex'),
125+
clientSessions['before-drop'].toString('hex'));
126+
assert.notStrictEqual(clientSessions['before-drop'].toString('hex'),
127+
clientSessions['after-drop'].toString('hex'));
128128
assert.strictEqual(clientSessions['after-drop'].toString('hex'),
129129
clientSessions['after-drop-reuse'].toString('hex'));
130130
});

test/parallel/test-module-loading-error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ try {
2828
try {
2929
require();
3030
} catch (e) {
31-
assert.notEqual(e.toString().indexOf('missing path'), -1);
31+
assert.ok(e.toString().includes('missing path'));
3232
}
3333

3434
try {
3535
require({});
3636
} catch (e) {
37-
assert.notEqual(e.toString().indexOf('path must be a string'), -1);
37+
assert.ok(e.toString().includes('path must be a string'));
3838
}

test/parallel/test-net-keepalive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var echoServer = net.createServer(function(connection) {
1616
echoServer.close();
1717
}, 1), common.platformTimeout(100));
1818
connection.setTimeout(0);
19-
assert.notEqual(connection.setKeepAlive, undefined);
19+
assert.notStrictEqual(connection.setKeepAlive, undefined);
2020
// send a keepalive packet after 50 ms
2121
connection.setKeepAlive(true, common.platformTimeout(50));
2222
connection.on('end', function() {

test/parallel/test-net-listen-exclusive-random-ports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (cluster.isMaster) {
1515

1616
worker2.on('message', function(port2) {
1717
assert.equal(port2, port2 | 0, 'second worker could not listen');
18-
assert.notEqual(port1, port2, 'ports should not be equal');
18+
assert.notStrictEqual(port1, port2, 'ports should not be equal');
1919
worker1.kill();
2020
worker2.kill();
2121
});

test/parallel/test-net-remote-address-port.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ var remoteFamilyCandidates = ['IPv4'];
1313
if (common.hasIPv6) remoteFamilyCandidates.push('IPv6');
1414

1515
var server = net.createServer(common.mustCall(function(socket) {
16-
assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress));
17-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily));
16+
assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
17+
assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily));
1818
assert.ok(socket.remotePort);
19-
assert.notEqual(socket.remotePort, this.address().port);
19+
assert.notStrictEqual(socket.remotePort, this.address().port);
2020
socket.on('end', function() {
2121
if (++conns_closed === 2) server.close();
2222
});
2323
socket.on('close', function() {
24-
assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress));
25-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily));
24+
assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
25+
assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily));
2626
});
2727
socket.resume();
2828
}, 2));
@@ -31,23 +31,23 @@ server.listen(0, 'localhost', function() {
3131
var client = net.createConnection(this.address().port, 'localhost');
3232
var client2 = net.createConnection(this.address().port);
3333
client.on('connect', function() {
34-
assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress));
35-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily));
34+
assert.ok(remoteAddrCandidates.includes(client.remoteAddress));
35+
assert.ok(remoteFamilyCandidates.includes(client.remoteFamily));
3636
assert.strictEqual(client.remotePort, server.address().port);
3737
client.end();
3838
});
3939
client.on('close', function() {
40-
assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress));
41-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily));
40+
assert.ok(remoteAddrCandidates.includes(client.remoteAddress));
41+
assert.ok(remoteFamilyCandidates.includes(client.remoteFamily));
4242
});
4343
client2.on('connect', function() {
44-
assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress));
45-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily));
44+
assert.ok(remoteAddrCandidates.includes(client2.remoteAddress));
45+
assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily));
4646
assert.strictEqual(client2.remotePort, server.address().port);
4747
client2.end();
4848
});
4949
client2.on('close', function() {
50-
assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress));
51-
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily));
50+
assert.ok(remoteAddrCandidates.includes(client2.remoteAddress));
51+
assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily));
5252
});
5353
});

test/parallel/test-process-cpuUsage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ assert.throws(() => {
8787

8888
// Ensure that the return value is the expected shape.
8989
function validateResult(result) {
90-
assert.notEqual(result, null);
90+
assert.notStrictEqual(result, null);
9191

9292
assert(Number.isFinite(result.user));
9393
assert(Number.isFinite(result.system));

test/parallel/test-regress-GH-7511.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const vm = require('vm');
66
assert.doesNotThrow(function() {
77
var context = vm.createContext({ process: process });
88
var result = vm.runInContext('process.env["PATH"]', context);
9-
assert.notEqual(undefined, result);
9+
assert.notStrictEqual(undefined, result);
1010
});

test/parallel/test-regress-GH-node-9326.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ var cp = child_process.spawn(process.execPath, [
1010
]);
1111

1212
cp.on('exit', function(code) {
13-
assert.notEqual(code, 0);
13+
assert.notStrictEqual(code, 0);
1414
});

test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const assert = require('assert');
66
const content = require(common.fixturesDir +
77
'/json-with-directory-name-module/module-stub/one-trailing-slash/two/three.js');
88

9-
assert.notEqual(content.rocko, 'artischocko');
9+
assert.notStrictEqual(content.rocko, 'artischocko');
1010
assert.equal(content, 'hello from module-stub!');

test/parallel/test-socket-write-after-fin-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ server.listen(0, function() {
4949
assert(gotServerEnd);
5050
assert(gotServerError);
5151
assert.equal(gotServerError.code, 'EPIPE');
52-
assert.notEqual(gotServerError.message, 'write after end');
52+
assert.notStrictEqual(gotServerError.message, 'write after end');
5353
console.log('ok');
5454
});
5555

test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ timers.enroll(foo, 1);
3737
timers._unrefActive(foo);
3838

3939
setTimeout(function() {
40-
assert.notEqual(nbTimersFired, 2);
40+
assert.notStrictEqual(nbTimersFired, 2);
4141
}, 20);

test/parallel/test-tls-handshake-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var server = tls.createServer({
2525
});
2626

2727
c.on('error', common.mustCall(function(err) {
28-
assert.notEqual(err.code, 'ECONNRESET');
28+
assert.notStrictEqual(err.code, 'ECONNRESET');
2929
}));
3030

3131
c.on('close', common.mustCall(function(err) {

test/parallel/test-tls-set-ciphers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const reply = 'I AM THE WALRUS'; // something recognizable
2626
let response = '';
2727

2828
process.on('exit', function() {
29-
assert.notEqual(response.indexOf(reply), -1);
29+
assert.ok(response.includes(reply));
3030
});
3131

3232
const server = tls.createServer(options, common.mustCall(function(conn) {

test/parallel/test-whatwg-url-searchparams-constructor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ assert.throws(() => {
2626
});
2727
}, TypeError);
2828
params = new URLSearchParams('');
29-
assert.notEqual(params, null, 'constructor returned non-null value.');
29+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
3030
// eslint-disable-next-line no-proto
3131
assert.strictEqual(params.__proto__, URLSearchParams.prototype,
3232
'expected URLSearchParams.prototype as prototype.');
@@ -36,19 +36,19 @@ assert.strictEqual(params + '', '%5Bobject%20Object%5D=');
3636

3737
// URLSearchParams constructor, string.
3838
params = new URLSearchParams('a=b');
39-
assert.notEqual(params, null, 'constructor returned non-null value.');
39+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
4040
assert.strictEqual(true, params.has('a'),
4141
'Search params object has name "a"');
4242
assert.strictEqual(false, params.has('b'),
4343
'Search params object has not got name "b"');
4444
params = new URLSearchParams('a=b&c');
45-
assert.notEqual(params, null, 'constructor returned non-null value.');
45+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
4646
assert.strictEqual(true, params.has('a'),
4747
'Search params object has name "a"');
4848
assert.strictEqual(true, params.has('c'),
4949
'Search params object has name "c"');
5050
params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8');
51-
assert.notEqual(params, null, 'constructor returned non-null value.');
51+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
5252
assert.strictEqual(true, params.has('a'), 'Search params object has name "a"');
5353
assert.strictEqual(true, params.has('a b'),
5454
'Search params object has name "a b"');
@@ -64,7 +64,7 @@ assert.strictEqual(true, params.has('møø'),
6464
// URLSearchParams constructor, object.
6565
const seed = new URLSearchParams('a=b&c=d');
6666
params = new URLSearchParams(seed);
67-
assert.notEqual(params, null, 'constructor returned non-null value.');
67+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
6868
assert.strictEqual(params.get('a'), 'b');
6969
assert.strictEqual(params.get('c'), 'd');
7070
assert.strictEqual(false, params.has('d'));

test/parallel/test-whatwg-url-searchparams-get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assert.strictEqual(params.get('a'), '');
2020

2121
// More get() basics
2222
params = new URLSearchParams('first=second&third&&');
23-
assert.notEqual(params, null, 'constructor returned non-null value.');
23+
assert.notStrictEqual(params, null, 'constructor returned non-null value.');
2424
assert.strictEqual(true, params.has('first'),
2525
'Search params object has name "first"');
2626
assert.strictEqual(params.get('first'), 'second',

test/parallel/test-zlib-sync-no-event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ const unzipper = new zlib.Gunzip();
1717
unzipper.on('close', shouldNotBeCalled);
1818

1919
const unzipped = unzipper._processChunk(zipped, zlib.constants.Z_FINISH);
20-
assert.notEqual(zipped.toString(), message);
20+
assert.notStrictEqual(zipped.toString(), message);
2121
assert.strictEqual(unzipped.toString(), message);

0 commit comments

Comments
 (0)