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 <[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]>
diff --git a/test/parallel/test-dgram-bind-shared-ports.js b/test/parallel/test-dgram-bind-shared-ports.js
index dcd96d7..474c352 100644
--- a/test/parallel/test-dgram-bind-shared-ports.js
+++ b/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 @@
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 @@
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');
});