test: refactor event-emitter-remove-all-listeners#13165
test: refactor event-emitter-remove-all-listeners#13165Trott wants to merge 1 commit intonodejs:masterfrom
Conversation
Use common.mustNotCall() to confirm that listener handles never run (as no events are emitted).
| ee.on('bar', common.noop); | ||
| ee.on('baz', common.noop); | ||
| ee.on('baz', common.noop); | ||
| const noop = common.mustNotCall(); |
There was a problem hiding this comment.
Why not bring this up to the parent scope and use it in the other places below that are now manually calling common.mustNotCall()?
There was a problem hiding this comment.
+1
But give it a better name... maybe mustNotCall or if your thight with char dontCall or even doNot
There was a problem hiding this comment.
Why not bring this up to the parent scope and use it in the other places below that are now manually calling common.mustNotCall()?
@mscdex Happy to do that if there's consensus that it would be an improvement. I didn't do it because:
-
It's not needed as an identifier in the other scopes. (It's needed here because of the
assert.deepStrictEqual()comparisons.) -
Fewer global identifiers shared across different block scopes helps make those things easily cut-and-paste-able into separate test files for refactoring, etc. It also helps limit the possibility of side effects. (For example, if another test attaches a property to the
noopfunction for some reason, that property will be set for all the other tests.)
But this isn't far off from a tabs-vs-spaces discussion, so I'm happy to just do it if everyone else thinks differently than me. :-D
|
Landed in 4384f2e |
Use common.mustNotCall() to confirm that listener handles never run (as no events are emitted). PR-URL: nodejs#13165 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Use common.mustNotCall() to confirm that listener handles never run (as no events are emitted). PR-URL: #13165 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
|
This does not land cleanly in LTS. Please feel free to manually backport. Please also feel free to replace do-not-land if it is being backported |
Use common.mustNotCall() to confirm that listener handles never run (as
no events are emitted).
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test events