0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-process-emit.js
Evan Lucas 31ebda24d4 node: set process._eventsCount to 0 on startup
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: https://github.com/nodejs/node/pull/5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-15 09:33:17 -06:00

23 lines
562 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const sym = Symbol();
process.on('normal', common.mustCall((data) => {
assert.strictEqual(data, 'normalData');
}));
process.on(sym, common.mustCall((data) => {
assert.strictEqual(data, 'symbolData');
}));
process.on('SIGPIPE', common.mustCall((data) => {
assert.strictEqual(data, 'signalData');
}));
process.emit('normal', 'normalData');
process.emit(sym, 'symbolData');
process.emit('SIGPIPE', 'signalData');
assert.strictEqual(isNaN(process._eventsCount), false);