Skip to content

Commit 122917d

Browse files
Daniel SimsMylesBorins
authored andcommitted
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 <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent d5e911c commit 122917d

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varfork=require('child_process').fork;
5-
varnet=require('net');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constfork=require('child_process').fork;
5+
constnet=require('net');
66

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

10-
varworker=fork(__filename,['child']);
11-
varcalled=false;
10+
constworker=fork(__filename,['child']);
11+
letcalled=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-
varsocket;
35-
varcbcalls=0;
34+
letsocket;
35+
letcbcalls=0;
3636
functionsocketConnected(){
3737
if(++cbcalls===2)
3838
process.send('handle',socket);
3939
}
4040

41-
varserver=net.createServer(function(c){
42-
process.once('message',function(msg){
43-
assert.equal(msg,'got');
41+
constserver=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)