mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 21:49:48 +00:00

PR-URL: https://github.com/nodejs/node/pull/38582 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
19 lines
486 B
JavaScript
19 lines
486 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const EventEmitter = require('events');
|
|
|
|
// Test emit called by other context
|
|
const EE = new EventEmitter();
|
|
|
|
// Works as expected if the context has no `constructor.name`
|
|
{
|
|
const ctx = Object.create(null);
|
|
assert.throws(
|
|
() => EE.emit.call(ctx, 'error', new Error('foo')),
|
|
common.expectsError({ name: 'Error', message: 'foo' })
|
|
);
|
|
}
|
|
|
|
assert.strictEqual(EE.emit.call({}, 'foo'), false);
|