2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-10-13 04:52:26 +08:00
|
|
|
var events = require('events');
|
|
|
|
|
|
|
|
var e = new events.EventEmitter();
|
|
|
|
var times_hello_emited = 0;
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
e.once('hello', function(a, b) {
|
2010-10-13 04:52:26 +08:00
|
|
|
times_hello_emited++;
|
|
|
|
});
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
2010-10-13 04:52:26 +08:00
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
process.addListener('exit', function() {
|
2010-10-13 04:52:26 +08:00
|
|
|
assert.equal(1, times_hello_emited);
|
|
|
|
});
|
|
|
|
|