Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
test: increase coverage for lib/events.js#9865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
captainsafia commented Dec 1, 2016 • edited by Trott
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by Trott
Uh oh!
There was an error while loading. Please reload this page.
This adds tests for the case in which listeners() is invoked on a EventEmitter with no events.
bb6db3d to 6d63d0dCompare
Trott left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is ✅
Trott commented Dec 1, 2016
MylesBorins commented Dec 1, 2016
LGTM IF ci is green |
Trott commented Dec 1, 2016
Two failed hosts look CI infra related, not related to this test. But because EVERYONE LOVES GREEN, let's try again: https://ci.nodejs.org/job/node-test-pull-request/5037/ |
In the process of creating nodejs#9865, it was discovered that the code checking whether or not events was defined was unnecessary because the only situation in which events would be undefined is if it is monkeypatched by an external entity. This should be removed in order to discourage this. If the test added in nodejs#9865 is merged, it will need to removed on merge of this commit.
This adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set.
captainsafia commented Dec 1, 2016
I added tests for the case explored in #9866 in which |
Trott commented Dec 2, 2016
Thanks for adding the additional test! |
captainsafia commented Dec 2, 2016
@Trott: Great point! I've update the code. |
Trott commented Dec 2, 2016
addaleax left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM :)
Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: nodejs#9865 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Trott commented Dec 3, 2016
Landed in a912b79 |
Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: #9865 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: nodejs#9865 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: #9865 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: #9865 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Myles Borins <[email protected]>
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
test, events
Description of change
This adds a test for the case in which listeners() is invoked on an
EventEmitter with no events.
Note that the EventEmitter does not allow
_eventsto ever beundefined as it is instantiated in the initializer. The only situation in
which it might be undefined is if it is monkey-patched externally.
Because of this, the added tests monkey-patches
this._eventstomimic this expected behavior.