Skip to content

Commit 0bfd103

Browse files
Fikret Burak Gaziogluimyller
authored andcommitted
test: refactor test-dgram-bind-shared-ports.js
Refactored the code to latest standards, where all var is changed to const, functions are changed to arrow functions and assert.equal chaned to assert.strictEqual PR-URL: #8582 Reviewed-By: Robert Jefe Lindstaedt <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
1 parent d7994db commit 0bfd103

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

test/parallel/test-dgram-bind-shared-ports.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var cluster = require('cluster');
5-
var dgram = require('dgram');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const cluster = require('cluster');
5+
const dgram = require('dgram');
66

7-
function noop() {}
7+
function noop() { }
88

99
if (cluster.isMaster) {
10-
var worker1 = cluster.fork();
10+
const worker1 = cluster.fork();
1111

1212
if (common.isWindows) {
13-
var checkErrType = function(er) {
14-
assert.equal(er.code, 'ENOTSUP');
13+
const checkErrType = (er) => {
14+
assert.strictEqual(er.code, 'ENOTSUP');
1515
worker1.kill();
1616
};
1717

1818
worker1.on('error', common.mustCall(checkErrType, 1));
1919
return;
2020
}
2121

22-
worker1.on('message', function(msg) {
23-
assert.equal(msg, 'success');
24-
var worker2 = cluster.fork();
22+
worker1.on('message', (msg) => {
23+
assert.strictEqual(msg, 'success');
24+
const worker2 = cluster.fork();
2525

26-
worker2.on('message', function(msg) {
27-
assert.equal(msg, 'socket2:EADDRINUSE');
26+
worker2.on('message', (msg) => {
27+
assert.strictEqual(msg, 'socket2:EADDRINUSE');
2828
worker1.kill();
2929
worker2.kill();
3030
});
3131
});
3232
} else {
33-
var socket1 = dgram.createSocket('udp4', noop);
34-
var socket2 = dgram.createSocket('udp4', noop);
33+
const socket1 = dgram.createSocket('udp4', noop);
34+
const socket2 = dgram.createSocket('udp4', noop);
3535

36-
socket1.on('error', function(err) {
36+
socket1.on('error', (err) => {
3737
// no errors expected
3838
process.send('socket1:' + err.code);
3939
});
4040

41-
socket2.on('error', function(err) {
41+
socket2.on('error', (err) => {
4242
// an error is expected on the second worker
4343
process.send('socket2:' + err.code);
4444
});
@@ -47,8 +47,8 @@ if (cluster.isMaster) {
4747
address: 'localhost',
4848
port: common.PORT,
4949
exclusive: false
50-
}, function() {
51-
socket2.bind({port: common.PORT + 1, exclusive: true}, function() {
50+
}, () => {
51+
socket2.bind({ port: common.PORT + 1, exclusive: true }, () => {
5252
// the first worker should succeed
5353
process.send('success');
5454
});

0 commit comments

Comments
 (0)