* test else path in emitMany function * test calling removeAllListeners() in a event emitter instance with no events at all * test calling removeListener() passing a event type that does not exist * test calling eventNames() in a event emitter instance with no events at all Refs: https://coverage.nodejs.org/coverage-ba776b3a56642d4c/root/events.js.html PR-URL: https://github.com/nodejs/node/pull/10947 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
33 lines
773 B
JavaScript
33 lines
773 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const events = require('events');
|
|
|
|
const e = new events.EventEmitter();
|
|
const num_args_emitted = [];
|
|
|
|
e.on('numArgs', function() {
|
|
const numArgs = arguments.length;
|
|
num_args_emitted.push(numArgs);
|
|
});
|
|
|
|
e.on('foo', function() {
|
|
num_args_emitted.push(arguments.length);
|
|
});
|
|
|
|
e.on('foo', function() {
|
|
num_args_emitted.push(arguments.length);
|
|
});
|
|
|
|
e.emit('numArgs');
|
|
e.emit('numArgs', null);
|
|
e.emit('numArgs', null, null);
|
|
e.emit('numArgs', null, null, null);
|
|
e.emit('numArgs', null, null, null, null);
|
|
e.emit('numArgs', null, null, null, null, null);
|
|
|
|
e.emit('foo', null, null, null, null);
|
|
|
|
process.on('exit', function() {
|
|
assert.deepStrictEqual([0, 1, 2, 3, 4, 5, 4, 4], num_args_emitted);
|
|
});
|