@@ -38,24 +38,25 @@ function expect(expected) {
38
38
39
39
{
40
40
const ee = new events . EventEmitter ( ) ;
41
- ee . on ( 'foo' , common . noop ) ;
42
- ee . on ( 'bar' , common . noop ) ;
43
- ee . on ( 'baz' , common . noop ) ;
44
- ee . on ( 'baz' , common . noop ) ;
41
+ const noop = common . mustNotCall ( ) ;
42
+ ee . on ( 'foo' , noop ) ;
43
+ ee . on ( 'bar' , noop ) ;
44
+ ee . on ( 'baz' , noop ) ;
45
+ ee . on ( 'baz' , noop ) ;
45
46
const fooListeners = ee . listeners ( 'foo' ) ;
46
47
const barListeners = ee . listeners ( 'bar' ) ;
47
48
const bazListeners = ee . listeners ( 'baz' ) ;
48
49
ee . on ( 'removeListener' , expect ( [ 'bar' , 'baz' , 'baz' ] ) ) ;
49
50
ee . removeAllListeners ( 'bar' ) ;
50
51
ee . removeAllListeners ( 'baz' ) ;
51
- assert . deepStrictEqual ( ee . listeners ( 'foo' ) , [ common . noop ] ) ;
52
+ assert . deepStrictEqual ( ee . listeners ( 'foo' ) , [ noop ] ) ;
52
53
assert . deepStrictEqual ( ee . listeners ( 'bar' ) , [ ] ) ;
53
54
assert . deepStrictEqual ( ee . listeners ( 'baz' ) , [ ] ) ;
54
55
// After calling removeAllListeners(),
55
56
// the old listeners array should stay unchanged.
56
- assert . deepStrictEqual ( fooListeners , [ common . noop ] ) ;
57
- assert . deepStrictEqual ( barListeners , [ common . noop ] ) ;
58
- assert . deepStrictEqual ( bazListeners , [ common . noop , common . noop ] ) ;
57
+ assert . deepStrictEqual ( fooListeners , [ noop ] ) ;
58
+ assert . deepStrictEqual ( barListeners , [ noop ] ) ;
59
+ assert . deepStrictEqual ( bazListeners , [ noop , noop ] ) ;
59
60
// After calling removeAllListeners(),
60
61
// new listeners arrays is different from the old.
61
62
assert . notStrictEqual ( ee . listeners ( 'bar' ) , barListeners ) ;
@@ -64,8 +65,8 @@ function expect(expected) {
64
65
65
66
{
66
67
const ee = new events . EventEmitter ( ) ;
67
- ee . on ( 'foo' , common . noop ) ;
68
- ee . on ( 'bar' , common . noop ) ;
68
+ ee . on ( 'foo' , common . mustNotCall ( ) ) ;
69
+ ee . on ( 'bar' , common . mustNotCall ( ) ) ;
69
70
// Expect LIFO order
70
71
ee . on ( 'removeListener' , expect ( [ 'foo' , 'bar' , 'removeListener' ] ) ) ;
71
72
ee . on ( 'removeListener' , expect ( [ 'foo' , 'bar' ] ) ) ;
@@ -76,7 +77,7 @@ function expect(expected) {
76
77
77
78
{
78
79
const ee = new events . EventEmitter ( ) ;
79
- ee . on ( 'removeListener' , common . noop ) ;
80
+ ee . on ( 'removeListener' , common . mustNotCall ( ) ) ;
80
81
// Check for regression where removeAllListeners() throws when
81
82
// there exists a 'removeListener' listener, but there exists
82
83
// no listeners for the provided event type.
@@ -89,9 +90,9 @@ function expect(expected) {
89
90
ee . on ( 'removeListener' , function ( name , noop ) {
90
91
assert . strictEqual ( expectLength -- , this . listeners ( 'baz' ) . length ) ;
91
92
} ) ;
92
- ee . on ( 'baz' , common . noop ) ;
93
- ee . on ( 'baz' , common . noop ) ;
94
- ee . on ( 'baz' , common . noop ) ;
93
+ ee . on ( 'baz' , common . mustNotCall ( ) ) ;
94
+ ee . on ( 'baz' , common . mustNotCall ( ) ) ;
95
+ ee . on ( 'baz' , common . mustNotCall ( ) ) ;
95
96
assert . strictEqual ( ee . listeners ( 'baz' ) . length , expectLength + 1 ) ;
96
97
ee . removeAllListeners ( 'baz' ) ;
97
98
assert . strictEqual ( ee . listeners ( 'baz' ) . length , 0 ) ;
0 commit comments