0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/test-setTimeout.js

18 lines
421 B
JavaScript
Raw Normal View History

include("mjsunit");
function on_load () {
assertInstanceof(setTimeout, Function);
var starttime = new Date;
2009-04-21 16:22:14 +02: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 16:22:14 +02:00
// this timer shouldn't execute
var id = setTimeout(function () { assertTrue(false); }, 500);
clearTimeout(id);
}