Skip to content

Commit

Permalink
test: refactor test-dgram-bind-shared-ports.js
Browse files Browse the repository at this point in the history
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 <robert.lindstaedt@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
  • Loading branch information
Fikret Burak Gazioglu authored and imyller committed Sep 20, 2016
1 parent d7994db commit 0bfd103
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions test/parallel/test-dgram-bind-shared-ports.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var dgram = require('dgram');
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');

function noop() {}
function noop() { }

if (cluster.isMaster) {
var worker1 = cluster.fork();
const worker1 = cluster.fork();

if (common.isWindows) {
var checkErrType = function(er) {
assert.equal(er.code, 'ENOTSUP');
const checkErrType = (er) => {
assert.strictEqual(er.code, 'ENOTSUP');
worker1.kill();
};

worker1.on('error', common.mustCall(checkErrType, 1));
return;
}

worker1.on('message', function(msg) {
assert.equal(msg, 'success');
var worker2 = cluster.fork();
worker1.on('message', (msg) => {
assert.strictEqual(msg, 'success');
const worker2 = cluster.fork();

worker2.on('message', function(msg) {
assert.equal(msg, 'socket2:EADDRINUSE');
worker2.on('message', (msg) => {
assert.strictEqual(msg, 'socket2:EADDRINUSE');
worker1.kill();
worker2.kill();
});
});
} else {
var socket1 = dgram.createSocket('udp4', noop);
var socket2 = dgram.createSocket('udp4', noop);
const socket1 = dgram.createSocket('udp4', noop);
const socket2 = dgram.createSocket('udp4', noop);

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

socket2.on('error', function(err) {
socket2.on('error', (err) => {
// an error is expected on the second worker
process.send('socket2:' + err.code);
});
Expand All @@ -47,8 +47,8 @@ if (cluster.isMaster) {
address: 'localhost',
port: common.PORT,
exclusive: false
}, function() {
socket2.bind({port: common.PORT + 1, exclusive: true}, function() {
}, () => {
socket2.bind({ port: common.PORT + 1, exclusive: true }, () => {
// the first worker should succeed
process.send('success');
});
Expand Down

0 comments on commit 0bfd103

Please sign in to comment.