Browse Source

Add test for setInterval

v0.7.4-release
Ryan 16 years ago
parent
commit
3886e183fd
  1. 14
      test/test-setTimeout.js

14
test/test-setTimeout.js

@ -14,4 +14,18 @@ function onLoad () {
// this timer shouldn't execute
var id = setTimeout(function () { assertTrue(false); }, 500);
clearTimeout(id);
var count = 0;
setInterval(function () {
count += 1;
var endtime = new Date;
var diff = endtime - starttime;
if (diff < 0) diff = -diff;
puts(diff);
var t = count * 1000;
assertTrue(t - 100 < diff || diff < t + 100);
assertTrue(count <= 3);
if (count == 3)
clearInterval(this);
}, 1000);
}

Loading…
Cancel
Save