mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 23:06:47 +00:00

Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
44 lines
908 B
JavaScript
44 lines
908 B
JavaScript
'use strict';
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
var util = require('util');
|
|
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);
|
|
});
|