Skip to content

Commit 1c21166

Browse files
Daniel SimsMylesBorins
Daniel Sims
authored andcommittedJan 24, 2017
test: change var declarations, add mustCall check
In this test, I changed the var declarations to be either a let or a const. For some of the callbacks, I added a mustCall check to ensure that the functions have run. I also changed assert.equal() to assert.strictEqual(). PR-URL: #9962 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 6bdd59a commit 1c21166

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed
 

‎test/parallel/test-cluster-net-send.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var fork = require('child_process').fork;
5-
var net = require('net');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const fork = require('child_process').fork;
5+
const net = require('net');
66

77
if (process.argv[2] !== 'child') {
88
console.error('[%d] master', process.pid);
99

10-
var worker = fork(__filename, ['child']);
11-
var called = false;
10+
const worker = fork(__filename, ['child']);
11+
let called = false;
1212

13-
worker.once('message', function(msg, handle) {
14-
assert.equal(msg, 'handle');
13+
worker.once('message', common.mustCall(function(msg, handle) {
14+
assert.strictEqual(msg, 'handle');
1515
assert.ok(handle);
1616
worker.send('got');
1717

1818
handle.on('data', function(data) {
1919
called = true;
20-
assert.equal(data.toString(), 'hello');
20+
assert.strictEqual(data.toString(), 'hello');
2121
});
2222

2323
handle.on('end', function() {
2424
worker.kill();
2525
});
26-
});
26+
}));
2727

2828
process.once('exit', function() {
2929
assert.ok(called);
3030
});
3131
} else {
3232
console.error('[%d] worker', process.pid);
3333

34-
var socket;
35-
var cbcalls = 0;
34+
let socket;
35+
let cbcalls = 0;
3636
function socketConnected() {
3737
if (++cbcalls === 2)
3838
process.send('handle', socket);
3939
}
4040

41-
var server = net.createServer(function(c) {
42-
process.once('message', function(msg) {
43-
assert.equal(msg, 'got');
41+
const server = net.createServer(function(c) {
42+
process.once('message', common.mustCall(function(msg) {
43+
assert.strictEqual(msg, 'got');
4444
c.end('hello');
45-
});
45+
}));
4646
socketConnected();
4747
});
48+
4849
server.listen(common.PORT, function() {
4950
socket = net.connect(common.PORT, '127.0.0.1', socketConnected);
5051
});

0 commit comments

Comments
 (0)