mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
f29762f4dd
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>
97 lines
1.7 KiB
JavaScript
97 lines
1.7 KiB
JavaScript
'use strict';
|
|
// Flags: --abort_on_uncaught_exception
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var domain = require('domain');
|
|
|
|
var tests = [
|
|
nextTick,
|
|
timer,
|
|
timerPlusNextTick,
|
|
netServer,
|
|
firstRun,
|
|
];
|
|
|
|
var errors = 0;
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(errors, tests.length);
|
|
});
|
|
|
|
tests.forEach(function(test) { test(); });
|
|
|
|
function nextTick() {
|
|
var d = domain.create();
|
|
|
|
d.once('error', function(err) {
|
|
errors += 1;
|
|
});
|
|
d.run(function() {
|
|
process.nextTick(function() {
|
|
throw new Error('exceptional!');
|
|
});
|
|
});
|
|
}
|
|
|
|
function timer() {
|
|
var d = domain.create();
|
|
|
|
d.on('error', function(err) {
|
|
errors += 1;
|
|
});
|
|
d.run(function() {
|
|
setTimeout(function() {
|
|
throw new Error('exceptional!');
|
|
}, 33);
|
|
});
|
|
}
|
|
|
|
function timerPlusNextTick() {
|
|
var d = domain.create();
|
|
|
|
d.on('error', function(err) {
|
|
errors += 1;
|
|
});
|
|
d.run(function() {
|
|
setTimeout(function() {
|
|
process.nextTick(function() {
|
|
throw new Error('exceptional!');
|
|
});
|
|
}, 33);
|
|
});
|
|
}
|
|
|
|
function firstRun() {
|
|
var d = domain.create();
|
|
|
|
d.on('error', function(err) {
|
|
errors += 1;
|
|
});
|
|
d.run(function() {
|
|
throw new Error('exceptional!');
|
|
});
|
|
}
|
|
|
|
function netServer() {
|
|
var net = require('net');
|
|
var d = domain.create();
|
|
|
|
d.on('error', function(err) {
|
|
errors += 1;
|
|
});
|
|
d.run(function() {
|
|
var server = net.createServer(function(conn) {
|
|
conn.pipe(conn);
|
|
});
|
|
server.listen(common.PORT, '0.0.0.0', function() {
|
|
var conn = net.connect(common.PORT, '0.0.0.0');
|
|
conn.once('data', function() {
|
|
throw new Error('ok');
|
|
});
|
|
conn.end('ok');
|
|
server.close();
|
|
});
|
|
});
|
|
}
|