Browse Source

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: https://github.com/nodejs/node/pull/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>
v6.x
Fikret Burak Gazioglu 8 years ago
committed by Jeremiah Senkpiel
parent
commit
d4ad8d9619
  1. 38
      test/parallel/test-dgram-bind-shared-ports.js

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

@ -1,17 +1,17 @@
'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();
};
@ -19,26 +19,26 @@ if (cluster.isMaster) {
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);
});
@ -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');
});

Loading…
Cancel
Save