summaryrefslogtreecommitdiff
path: root/test/parallel/test-timers-zero-timeout.js
blob: 939b8db1bb30db9abd602b99b9a88801e77589c5 (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
27
28
29
30
31
32
33
34
35
36
37
38
var common = require('../common');
var assert = require('assert');

// https://github.com/joyent/node/issues/2079 - zero timeout drops extra args
(function() {
  var ncalled = 0;

  setTimeout(f, 0, 'foo', 'bar', 'baz');
  var timer = setTimeout(function() {}, 0);

  function f(a, b, c) {
    assert.equal(a, 'foo');
    assert.equal(b, 'bar');
    assert.equal(c, 'baz');
    ncalled++;
  }

  process.on('exit', function() {
    assert.equal(ncalled, 1);
  });
})();

(function() {
  var ncalled = 0;

  var iv = setInterval(f, 0, 'foo', 'bar', 'baz');

  function f(a, b, c) {
    assert.equal(a, 'foo');
    assert.equal(b, 'bar');
    assert.equal(c, 'baz');
    if (++ncalled == 3) clearTimeout(iv);
  }

  process.on('exit', function() {
    assert.equal(ncalled, 3);
  });
})();