diff options
author | jseagull <jseagull@aliyun.com> | 2016-10-10 18:47:07 +0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-10-26 12:59:53 -0700 |
commit | 254ab63832186ba2cfd87c9f2dfc0ce7a41a1989 (patch) | |
tree | acb95af59cb0fa24eb54f31754935a30b6fd7443 /test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js | |
parent | f45eb1698ef920ccfd0aa5e861c68fd3e04e1e09 (diff) | |
download | android-node-v8-254ab63832186ba2cfd87c9f2dfc0ce7a41a1989.tar.gz android-node-v8-254ab63832186ba2cfd87c9f2dfc0ce7a41a1989.tar.bz2 android-node-v8-254ab63832186ba2cfd87c9f2dfc0ce7a41a1989.zip |
events,test: fix TypeError in EventEmitter warning
Allows Symbol to be converted to String so it can be included in the
error.
Fixes: https://github.com/nodejs/node/issues/9003
PR-URL: https://github.com/nodejs/node/pull/9021
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js')
-rw-r--r-- | test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js new file mode 100644 index 0000000000..fc0a3dba0e --- /dev/null +++ b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js @@ -0,0 +1,24 @@ +// Flags: --no-warnings +// The flag suppresses stderr output but the warning event will still emit +'use strict'; + +const common = require('../common'); +const events = require('events'); +const assert = require('assert'); + +const symbol = Symbol('symbol'); + +const e = new events.EventEmitter(); +e.setMaxListeners(1); + +process.on('warning', common.mustCall((warning) => { + assert.ok(warning instanceof Error); + assert.strictEqual(warning.name, 'MaxListenersExceededWarning'); + assert.strictEqual(warning.emitter, e); + assert.strictEqual(warning.count, 2); + assert.strictEqual(warning.type, symbol); + assert.ok(warning.message.includes('2 Symbol(symbol) listeners added.')); +})); + +e.on(symbol, function() {}); +e.on(symbol, function() {}); |