test: cleanup test-child-process-disconnect.js
Changed var --> const and let Changed assert.equal --> assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/8602 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
This commit is contained in:
parent
5f4bc59800
commit
13e110da72
@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
// child
|
// child
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
|
|
||||||
// Check that the 'disconnect' event is deferred to the next event loop tick.
|
// Check that the 'disconnect' event is deferred to the next event loop tick.
|
||||||
var disconnect = process.disconnect;
|
const disconnect = process.disconnect;
|
||||||
process.disconnect = function() {
|
process.disconnect = function() {
|
||||||
disconnect.apply(this, arguments);
|
disconnect.apply(this, arguments);
|
||||||
// If the event is emitted synchronously, we're too late by now.
|
// If the event is emitted synchronously, we're too late by now.
|
||||||
@ -17,7 +17,7 @@ if (process.argv[2] === 'child') {
|
|||||||
function disconnectIsNotAsync() {}
|
function disconnectIsNotAsync() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
var server = net.createServer();
|
const server = net.createServer();
|
||||||
|
|
||||||
server.on('connection', function(socket) {
|
server.on('connection', function(socket) {
|
||||||
|
|
||||||
@ -45,10 +45,10 @@ if (process.argv[2] === 'child') {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// testcase
|
// testcase
|
||||||
var child = fork(process.argv[1], ['child']);
|
const child = fork(process.argv[1], ['child']);
|
||||||
|
|
||||||
var childFlag = false;
|
let childFlag = false;
|
||||||
var parentFlag = false;
|
let parentFlag = false;
|
||||||
|
|
||||||
// when calling .disconnect the event should emit
|
// when calling .disconnect the event should emit
|
||||||
// and the disconnected flag should be true.
|
// and the disconnected flag should be true.
|
||||||
@ -64,7 +64,7 @@ if (process.argv[2] === 'child') {
|
|||||||
if (obj && obj.msg === 'ready') {
|
if (obj && obj.msg === 'ready') {
|
||||||
|
|
||||||
// connect to child using TCP to know if disconnect was emitted
|
// connect to child using TCP to know if disconnect was emitted
|
||||||
var socket = net.connect(obj.port);
|
const socket = net.connect(obj.port);
|
||||||
|
|
||||||
socket.on('data', function(data) {
|
socket.on('data', function(data) {
|
||||||
data = data.toString();
|
data = data.toString();
|
||||||
@ -84,7 +84,7 @@ if (process.argv[2] === 'child') {
|
|||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.equal(childFlag, false);
|
assert.strictEqual(childFlag, false);
|
||||||
assert.equal(parentFlag, false);
|
assert.strictEqual(parentFlag, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user