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>
This commit is contained in:
parent
d7994db70c
commit
0bfd103480
@ -1,17 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
var dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
||||||
function noop() {}
|
function noop() { }
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
var worker1 = cluster.fork();
|
const worker1 = cluster.fork();
|
||||||
|
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
var checkErrType = function(er) {
|
const checkErrType = (er) => {
|
||||||
assert.equal(er.code, 'ENOTSUP');
|
assert.strictEqual(er.code, 'ENOTSUP');
|
||||||
worker1.kill();
|
worker1.kill();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,26 +19,26 @@ if (cluster.isMaster) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
worker1.on('message', function(msg) {
|
worker1.on('message', (msg) => {
|
||||||
assert.equal(msg, 'success');
|
assert.strictEqual(msg, 'success');
|
||||||
var worker2 = cluster.fork();
|
const worker2 = cluster.fork();
|
||||||
|
|
||||||
worker2.on('message', function(msg) {
|
worker2.on('message', (msg) => {
|
||||||
assert.equal(msg, 'socket2:EADDRINUSE');
|
assert.strictEqual(msg, 'socket2:EADDRINUSE');
|
||||||
worker1.kill();
|
worker1.kill();
|
||||||
worker2.kill();
|
worker2.kill();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var socket1 = dgram.createSocket('udp4', noop);
|
const socket1 = dgram.createSocket('udp4', noop);
|
||||||
var socket2 = dgram.createSocket('udp4', noop);
|
const socket2 = dgram.createSocket('udp4', noop);
|
||||||
|
|
||||||
socket1.on('error', function(err) {
|
socket1.on('error', (err) => {
|
||||||
// no errors expected
|
// no errors expected
|
||||||
process.send('socket1:' + err.code);
|
process.send('socket1:' + err.code);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket2.on('error', function(err) {
|
socket2.on('error', (err) => {
|
||||||
// an error is expected on the second worker
|
// an error is expected on the second worker
|
||||||
process.send('socket2:' + err.code);
|
process.send('socket2:' + err.code);
|
||||||
});
|
});
|
||||||
@ -47,8 +47,8 @@ if (cluster.isMaster) {
|
|||||||
address: 'localhost',
|
address: 'localhost',
|
||||||
port: common.PORT,
|
port: common.PORT,
|
||||||
exclusive: false
|
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
|
// the first worker should succeed
|
||||||
process.send('success');
|
process.send('success');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user