node/test/parallel/test-beforeexit-event.js
Rich Trott 3311267f75 test: remove unused util imports
A number of tests in `test/parallel` were importing the `util` module
via `require()` but not using `util` for anything. This removes those
`require()` statements.

PR-URL: https://github.com/nodejs/node/pull/4397
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-12-25 13:16:26 -08:00

43 lines
880 B
JavaScript

'use strict';
var assert = require('assert');
var net = require('net');
var common = require('../common');
var revivals = 0;
var deaths = 0;
process.on('beforeExit', function() { deaths++; } );
process.once('beforeExit', tryImmediate);
function tryImmediate() {
console.log('set immediate');
setImmediate(function() {
revivals++;
process.once('beforeExit', tryTimer);
});
}
function tryTimer() {
console.log('set a timeout');
setTimeout(function() {
console.log('timeout cb, do another once beforeExit');
revivals++;
process.once('beforeExit', tryListen);
}, 1);
}
function tryListen() {
console.log('create a server');
net.createServer()
.listen(common.PORT)
.on('listening', function() {
revivals++;
this.close();
});
}
process.on('exit', function() {
assert.equal(4, deaths);
assert.equal(3, revivals);
});