mirror of https://github.com/lukechilds/node.git
Browse Source
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>v6
jseagull
8 years ago
committed by
James M Snell
5 changed files with 60 additions and 4 deletions
@ -0,0 +1,22 @@ |
|||||
|
// 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 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, null); |
||||
|
assert.ok(warning.message.includes('2 null listeners added.')); |
||||
|
})); |
||||
|
|
||||
|
e.on(null, function() {}); |
||||
|
e.on(null, function() {}); |
@ -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() {}); |
Loading…
Reference in new issue