mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 02:26:13 +00:00

The assert.throws() calls in test-event-emitter-max-listeners.js should include a constructor or RegExp as a second argument. PR-URL: https://github.com/nodejs/node/pull/9987 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
25 lines
658 B
JavaScript
25 lines
658 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const events = require('events');
|
|
const e = new events.EventEmitter();
|
|
|
|
e.on('maxListeners', common.mustCall(function() {}));
|
|
|
|
// Should not corrupt the 'maxListeners' queue.
|
|
e.setMaxListeners(42);
|
|
|
|
assert.throws(function() {
|
|
e.setMaxListeners(NaN);
|
|
}, /^TypeError: "n" argument must be a positive number$/);
|
|
|
|
assert.throws(function() {
|
|
e.setMaxListeners(-1);
|
|
}, /^TypeError: "n" argument must be a positive number$/);
|
|
|
|
assert.throws(function() {
|
|
e.setMaxListeners('and even this');
|
|
}, /^TypeError: "n" argument must be a positive number$/);
|
|
|
|
e.emit('maxListeners');
|