summaryrefslogtreecommitdiff
path: root/test/parallel/test-event-emitter-num-args.js
blob: e405b5b894a704c7470735b98558afd71b7ac651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
require('../common');
var assert = require('assert');
var events = require('events');

const e = new events.EventEmitter();
const num_args_emited = [];

e.on('numArgs', function() {
  var numArgs = arguments.length;
  console.log('numArgs: ' + numArgs);
  num_args_emited.push(numArgs);
});

console.log('start');

e.emit('numArgs');
e.emit('numArgs', null);
e.emit('numArgs', null, null);
e.emit('numArgs', null, null, null);
e.emit('numArgs', null, null, null, null);
e.emit('numArgs', null, null, null, null, null);

process.on('exit', function() {
  assert.deepEqual([0, 1, 2, 3, 4, 5], num_args_emited);
});