node/test/test-setTimeout.js

18 lines
420 B
JavaScript
Raw Normal View History

include("mjsunit");
2009-04-21 22:30:47 +08:00
function onLoad () {
assertInstanceof(setTimeout, Function);
var starttime = new Date;
2009-04-21 22:22:14 +08:00
setTimeout(function () {
var endtime = new Date;
var diff = endtime - starttime;
if (diff < 0) diff = -diff;
assertTrue(900 < diff || diff < 1100);
}, 1000);
2009-04-21 22:22:14 +08:00
// this timer shouldn't execute
var id = setTimeout(function () { assertTrue(false); }, 500);
clearTimeout(id);
}