diff --git a/src/node.js b/src/node.js index f329c0055c..a4ec922adc 100644 --- a/src/node.js +++ b/src/node.js @@ -604,7 +604,7 @@ global.setTimeout = function (callback, after) { global.setInterval = function (callback, repeat) { var timer = new process.Timer(); addTimerListener.apply(timer, arguments); - timer.start(repeat, repeat); + timer.start(repeat, repeat ? repeat : 1); return timer; }; diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index d656f2bf95..8b3c39efdd 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -74,7 +74,14 @@ setInterval(function(param1, param2){ clearInterval(this); }, 1000, "param1", "param2"); +// setInterval(cb, 0) should be called multiple times. +count4 = 0; +interval4 = setInterval(function () { + if (++count4 > 10) clearInterval(interval4); +}, 0); + process.addListener("exit", function () { assert.equal(true, setTimeout_called); assert.equal(3, interval_count); + assert.equal(11, count4); });