Skip to content

Commit

Permalink
temp: fix prefer-assert-methods violations
Browse files Browse the repository at this point in the history
  • Loading branch information
danyshaanan committed Sep 17, 2016
1 parent da23703 commit dada443
Show file tree
Hide file tree
Showing 46 changed files with 112 additions and 91 deletions.
4 changes: 2 additions & 2 deletions test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ fs.writeFileSync(addonDestinationPath, contents);

// Attempt to load at long path destination
var addon = require(addonDestinationPath);
assert(addon != null);
assert(addon.hello() == 'world');
assert.notEqual(addon, null);
assert.equal(addon.hello(), 'world');
2 changes: 1 addition & 1 deletion test/gc/test-http-client-connaborted.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function status() {
console.log('Collected: %d/%d', countGC, count);
if (done === todo) {
console.log('All should be collected now.');
assert(count === countGC);
assert.strictEqual(count, countGC);
process.exit(0);
}
}
3 changes: 1 addition & 2 deletions test/gc/test-http-client-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ function status() {
console.log('Collected: %d/%d', countGC, count);
if (done === todo) {
console.log('All should be collected now.');
assert(count === countGC);
assert.strictEqual(count, countGC);
process.exit(0);
}
}

3 changes: 1 addition & 2 deletions test/gc/test-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ function status() {
console.log('Collected: %d/%d', countGC, count);
if (done === todo) {
console.log('All should be collected now.');
assert(count === countGC);
assert.strictEqual(count, countGC);
process.exit(0);
}
}

2 changes: 1 addition & 1 deletion test/gc/test-net-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function status() {
global.gc();
console.log('All should be collected now.');
console.log('Collected: %d/%d', countGC, count);
assert(count === countGC);
assert.strictEqual(count, countGC);
process.exit(0);
}, 200);
}
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-child-process-detached.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ child.stdout.on('data', function(data) {
});

process.on('exit', function() {
assert(persistentPid !== -1);
assert.notStrictEqual(persistentPid, -1);
assert.throws(function() {
process.kill(child.pid);
});
assert.doesNotThrow(function() {
process.kill(persistentPid);
});
});

2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-regr-gh-2847.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var server = net.createServer(function(s) {

worker.process.once('close', common.mustCall(function() {
// Otherwise the crash on `_channel.fd` access may happen
assert(worker.process._channel === null);
assert.strictEqual(worker.process._channel, null);
server.close();
}));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-setup-master-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cluster.on('setup', function() {
realArgs[realArgs.length - 1]);
});

assert(process.argv[process.argv.length - 1] !== 'OMG,OMG');
assert.notStrictEqual(process.argv[process.argv.length - 1], 'OMG,OMG');
process.argv.push('OMG,OMG');
process.argv.push('OMG,OMG');
cluster.setupMaster();
2 changes: 1 addition & 1 deletion test/parallel/test-domain-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var server = http.createServer(function(req, res) {
var data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]);

// this line will throw if you pick an unknown key
assert(data !== undefined, 'Data should not be undefined');
assert.notStrictEqual(data, undefined, 'Data should not be undefined');

res.writeHead(200);
res.end(data);
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-domain-top-level-error-handler-throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ if (process.argv[2] === 'child') {
});

child.on('close', function onChildClosed() {
assert(stderrOutput.indexOf(domainErrHandlerExMessage) !== -1);
assert(stderrOutput.indexOf(internalExMessage) === -1);
assert.notStrictEqual(
stderrOutput.indexOf(domainErrHandlerExMessage),
-1
);
assert.strictEqual(stderrOutput.indexOf(internalExMessage), -1);
});

child.on('exit', function onChildExited(exitCode, signal) {
Expand Down
20 changes: 10 additions & 10 deletions test/parallel/test-event-emitter-listeners-side-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ var fl; // foo listeners

fl = e.listeners('foo');
assert(Array.isArray(fl));
assert(fl.length === 0);
assert.strictEqual(fl.length, 0);
assert(!(e._events instanceof Object));
assert.deepStrictEqual(Object.keys(e._events), []);

e.on('foo', common.fail);
fl = e.listeners('foo');
assert(e._events.foo === common.fail);
assert.strictEqual(e._events.foo, common.fail);
assert(Array.isArray(fl));
assert(fl.length === 1);
assert(fl[0] === common.fail);
assert.strictEqual(fl.length, 1);
assert.strictEqual(fl[0], common.fail);

e.listeners('bar');

e.on('foo', assert.ok);
fl = e.listeners('foo');

assert(Array.isArray(e._events.foo));
assert(e._events.foo.length === 2);
assert(e._events.foo[0] === common.fail);
assert(e._events.foo[1] === assert.ok);
assert.strictEqual(e._events.foo.length, 2);
assert.strictEqual(e._events.foo[0], common.fail);
assert.strictEqual(e._events.foo[1], assert.ok);

assert(Array.isArray(fl));
assert(fl.length === 2);
assert(fl[0] === common.fail);
assert(fl[1] === assert.ok);
assert.strictEqual(fl.length, 2);
assert.strictEqual(fl[0], common.fail);
assert.strictEqual(fl[1], assert.ok);

console.log('ok');
2 changes: 1 addition & 1 deletion test/parallel/test-file-write-stream2.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ for (var i = 0; i < 11; i++) {
console.error('%d %j', i, ret);

// return false when i hits 10
assert(ret === (i != 10));
assert.strictEqual(ret, i != 10);
}
cb_occurred += 'write ';
8 changes: 4 additions & 4 deletions test/parallel/test-fs-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ if (!common.isWindows && process.getuid() === 0) {
}
}

assert(typeof fs.F_OK === 'number');
assert(typeof fs.R_OK === 'number');
assert(typeof fs.W_OK === 'number');
assert(typeof fs.X_OK === 'number');
assert.strictEqual(typeof fs.F_OK, 'number');
assert.strictEqual(typeof fs.R_OK, 'number');
assert.strictEqual(typeof fs.W_OK, 'number');
assert.strictEqual(typeof fs.X_OK, 'number');

fs.access(__filename, function(err) {
assert.strictEqual(err, null, 'error should not exist');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-mkdtemp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ common.refreshTmpDir();

const tmpFolder = fs.mkdtempSync(path.join(common.tmpDir, 'foo.'));

assert(path.basename(tmpFolder).length === 'foo.XXXXXX'.length);
assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
assert(common.fileExists(tmpFolder));

const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.'));
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-readfile-pipe-large.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
assert(stdout === dataExpected, 'it reads the file and outputs it');
assert(stderr === '', 'it does not write to stderr');
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
assert.strictEqual(stderr, '', 'it does not write to stderr');
console.log('ok');
});

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-readfile-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var cmd = 'cat ' + f + ' | ' + node + ' ' + f + ' child';
exec(cmd, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
assert(stdout === dataExpected, 'it reads the file and outputs it');
assert(stderr === '', 'it does not write to stderr');
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
assert.strictEqual(stderr, '', 'it does not write to stderr');
console.log('ok');
});
2 changes: 1 addition & 1 deletion test/parallel/test-fs-readfile-unlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fs.writeFileSync(fileName, buf);

fs.readFile(fileName, function(err, data) {
assert.ifError(err);
assert(data.length == buf.length);
assert.equal(data.length, buf.length);
assert.strictEqual(buf[0], 42);

fs.unlinkSync(fileName);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-readfilesync-pipe-large.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
assert(stdout === dataExpected, 'it reads the file and outputs it');
assert(stderr === '', 'it does not write to stderr');
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
assert.strictEqual(stderr, '', 'it does not write to stderr');
console.log('ok');
});

Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var fs = require('fs');
fs.stat('.', common.mustCall(function(err, stats) {
assert.ifError(err);
assert.ok(stats.mtime instanceof Date);
assert(this === global);
assert.strictEqual(this, global);
}));

fs.stat('.', common.mustCall(function(err, stats) {
Expand All @@ -17,7 +17,7 @@ fs.stat('.', common.mustCall(function(err, stats) {
fs.lstat('.', common.mustCall(function(err, stats) {
assert.ifError(err);
assert.ok(stats.mtime instanceof Date);
assert(this === global);
assert.strictEqual(this, global);
}));

// fstat
Expand All @@ -29,10 +29,10 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
assert.ifError(err);
assert.ok(stats.mtime instanceof Date);
fs.close(fd);
assert(this === global);
assert.strictEqual(this, global);
}));

assert(this === global);
assert.strictEqual(this, global);
}));

// fstatSync
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-write-stream-autoclose-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ stream.end();
stream.on('finish', common.mustCall(function() {
process.nextTick(common.mustCall(function() {
assert.strictEqual(stream.closed, undefined);
assert(stream.fd !== null);
assert.notStrictEqual(stream.fd, null);
next();
}));
}));
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-agent-destroyed-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var server = http.createServer(function(req, res) {
var request1 = http.get(requestOptions, function(response) {
// assert request2 is queued in the agent
var key = agent.getName(requestOptions);
assert(agent.requests[key].length === 1);
assert.strictEqual(agent.requests[key].length, 1);
console.log('got response1');
request1.socket.on('close', function() {
console.log('request1 socket closed');
Expand Down Expand Up @@ -51,7 +51,7 @@ var server = http.createServer(function(req, res) {
process.nextTick(function() {
// assert that the same socket was not assigned to request2,
// since it was destroyed.
assert(request1.socket !== request2.socket);
assert.notStrictEqual(request1.socket, request2.socket);
assert(!request2.socket.destroyed, 'the socket is destroyed');
});
});
Expand All @@ -62,7 +62,7 @@ var server = http.createServer(function(req, res) {
assert(!request2.socket.destroyed);
assert(request1.socket.destroyed);
// assert not reusing the same socket, since it was destroyed.
assert(request1.socket !== request2.socket);
assert.notStrictEqual(request1.socket, request2.socket);
console.log('got response2');
var gotClose = false;
var gotResponseEnd = false;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-byteswritten.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var httpServer = http.createServer(common.mustCall(function(req, res) {
httpServer.close();

res.on('finish', common.mustCall(function() {
assert(typeof req.connection.bytesWritten === 'number');
assert.strictEqual(typeof req.connection.bytesWritten, 'number');
assert(req.connection.bytesWritten > 0);
}));
res.writeHead(200, { 'Content-Type': 'text/plain' });
Expand Down
14 changes: 10 additions & 4 deletions test/parallel/test-http-client-default-headers-exist.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ var server = http.createServer(function(req, res) {

var requestHeaders = Object.keys(req.headers);
requestHeaders.forEach(function(header) {
assert(expectedHeaders[req.method].indexOf(header.toLowerCase()) !== -1,
header + ' shoud not exist for method ' + req.method);
assert.notStrictEqual(
expectedHeaders[req.method].indexOf(header.toLowerCase()),
-1,
header + ' shoud not exist for method ' + req.method
);
});

assert(requestHeaders.length === expectedHeaders[req.method].length,
'some headers were missing for method: ' + req.method);
assert.strictEqual(
requestHeaders.length,
expectedHeaders[req.method].length,
'some headers were missing for method: ' + req.method
);

if (expectedMethods.length === requestCount)
server.close();
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var util = require('util');

assert(Array.isArray(http.METHODS));
assert(http.METHODS.length > 0);
assert(http.METHODS.indexOf('GET') !== -1);
assert(http.METHODS.indexOf('HEAD') !== -1);
assert(http.METHODS.indexOf('POST') !== -1);
assert.notStrictEqual(http.METHODS.indexOf('GET'), -1);
assert.notStrictEqual(http.METHODS.indexOf('HEAD'), -1);
assert.notStrictEqual(http.METHODS.indexOf('POST'), -1);
assert.deepStrictEqual(util._extend([], http.METHODS), http.METHODS.sort());
2 changes: 1 addition & 1 deletion test/parallel/test-http-write-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function runTest() {
http.get({ port: this.address().port }, function(response) {
response.on('end', function() {
assert.equal(response.headers['test'], '2');
assert(response.rawHeaders.indexOf('Test') !== -1);
assert.notStrictEqual(response.rawHeaders.indexOf('Test'), -1);
s.close();
});
response.resume();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-byteswritten.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var body = 'hello world\n';

var httpsServer = https.createServer(options, function(req, res) {
res.on('finish', function() {
assert(typeof req.connection.bytesWritten === 'number');
assert.strictEqual(typeof req.connection.bytesWritten, 'number');
assert(req.connection.bytesWritten > 0);
httpsServer.close();
console.log('ok');
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-internal-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ assert.throws(function() {
require('internal/freelist');
});

assert(require(path.join(common.fixturesDir, 'internal-modules')) === 42);
assert.strictEqual(
require(path.join(common.fixturesDir, 'internal-modules')),
42
);
2 changes: 1 addition & 1 deletion test/parallel/test-process-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var path = require('path');
assert(process.hasOwnProperty('config'));

// ensure that `process.config` is an Object
assert(Object(process.config) === process.config);
assert.strictEqual(Object(process.config), process.config);

var configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
var config = fs.readFileSync(configPath, 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-getgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ if (typeof process.getgroups === 'function') {
}

function check(a, b) {
for (var i = 0; i < a.length; ++i) assert(b.indexOf(a[i]) !== -1);
for (var i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1);
}
2 changes: 1 addition & 1 deletion test/parallel/test-repl-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function testContext(repl) {
assert(context.console instanceof require('console').Console);

// ensure that the repl's global property is the context
assert(context.global === context);
assert.strictEqual(context.global, context);

// ensure that the repl console instance does not have a setter
assert.throws(() => context.console = 'foo');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-require-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ try {
} catch (err) {
var re = /test[\/\\]fixtures[\/\\]invalid.json: Unexpected string/;
var i = err.message.match(re);
assert(null !== i, 'require() json error should include path');
assert.notStrictEqual(null, i, 'require() json error should include path');
}
4 changes: 2 additions & 2 deletions test/parallel/test-stream-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ stream.push({ val: 1 });
stream.end({ val: 2 });

process.on('exit', function() {
assert(read.val === 1);
assert(written.val === 2);
assert.strictEqual(read.val, 1);
assert.strictEqual(written.val, 2);
});
Loading

0 comments on commit dada443

Please sign in to comment.