mirror of https://github.com/lukechilds/node.git
Browse Source
In the case of one defined listener, the function should only remove it if it is the same as the passed listener.v0.7.4-release
Jonas Pfenniger
15 years ago
committed by
Ryan Dahl
2 changed files with 40 additions and 1 deletions
@ -0,0 +1,39 @@ |
|||||
|
require("../common"); |
||||
|
var events = require('events'); |
||||
|
|
||||
|
|
||||
|
count = 0; |
||||
|
|
||||
|
function listener1 () { |
||||
|
puts('listener1'); |
||||
|
count++; |
||||
|
} |
||||
|
|
||||
|
function listener2 () { |
||||
|
puts('listener2'); |
||||
|
count++; |
||||
|
} |
||||
|
|
||||
|
function listener3 () { |
||||
|
puts('listener3'); |
||||
|
count++; |
||||
|
} |
||||
|
|
||||
|
e1 = new events.EventEmitter(); |
||||
|
e1.addListener("hello", listener1); |
||||
|
e1.removeListener("hello", listener1); |
||||
|
assert.deepEqual([], e1.listeners('hello')); |
||||
|
|
||||
|
e2 = new events.EventEmitter(); |
||||
|
e2.addListener("hello", listener1); |
||||
|
e2.removeListener("hello", listener2); |
||||
|
assert.deepEqual([listener1], e2.listeners('hello')); |
||||
|
|
||||
|
e3 = new events.EventEmitter(); |
||||
|
e3.addListener("hello", listener1); |
||||
|
e3.addListener("hello", listener2); |
||||
|
e3.removeListener("hello", listener1); |
||||
|
assert.deepEqual([listener2], e3.listeners('hello')); |
||||
|
|
||||
|
|
||||
|
|
Loading…
Reference in new issue