mirror of https://github.com/nodejs/node.git
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>pull/8660/head
parent
5f4bc59800
commit
13e110da72
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
var assert = require('assert');
|
||||
var fork = require('child_process').fork;
|
||||
var net = require('net');
|
||||
const assert = require('assert');
|
||||
const fork = require('child_process').fork;
|
||||
const net = require('net');
|
||||
|
||||
// child
|
||||
if (process.argv[2] === 'child') {
|
||||
|
||||
// Check that the 'disconnect' event is deferred to the next event loop tick.
|
||||
var disconnect = process.disconnect;
|
||||
const disconnect = process.disconnect;
|
||||
process.disconnect = function() {
|
||||
disconnect.apply(this, arguments);
|
||||
// If the event is emitted synchronously, we're too late by now.
|
||||
|
@ -17,7 +17,7 @@ if (process.argv[2] === 'child') {
|
|||
function disconnectIsNotAsync() {}
|
||||
};
|
||||
|
||||
var server = net.createServer();
|
||||
const server = net.createServer();
|
||||
|
||||
server.on('connection', function(socket) {
|
||||
|
||||
|
@ -45,10 +45,10 @@ if (process.argv[2] === 'child') {
|
|||
|
||||
} else {
|
||||
// testcase
|
||||
var child = fork(process.argv[1], ['child']);
|
||||
const child = fork(process.argv[1], ['child']);
|
||||
|
||||
var childFlag = false;
|
||||
var parentFlag = false;
|
||||
let childFlag = false;
|
||||
let parentFlag = false;
|
||||
|
||||
// when calling .disconnect the event should emit
|
||||
// and the disconnected flag should be true.
|
||||
|
@ -64,7 +64,7 @@ if (process.argv[2] === 'child') {
|
|||
if (obj && obj.msg === 'ready') {
|
||||
|
||||
// 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) {
|
||||
data = data.toString();
|
||||
|
@ -84,7 +84,7 @@ if (process.argv[2] === 'child') {
|
|||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(childFlag, false);
|
||||
assert.equal(parentFlag, false);
|
||||
assert.strictEqual(childFlag, false);
|
||||
assert.strictEqual(parentFlag, false);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue