Skip to content
Permalink
Browse files

test, feat: add test case of timers.call.

  • Loading branch information...
xicilion committed Jul 27, 2018
1 parent 973270c commit b6d44ff5e9c7370b9fa06322bcd6dff36837d2c9
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/timer_test.js
@@ -435,6 +435,33 @@ describe("timer", () => {
test(timers.setHrInterval, timers.clearHrInterval);
});
});

it("timeout call", () => {
function test1() {
while (true);
}

function test2() {
while (true)
coroutine.sleep(100);
}

var t1 = new Date();
assert.throws(() => {
timers.call(test1, 30);
});
var t2 = new Date();
assert.greaterThan(t2 - t1, 25);
assert.lessThan(t2 - t1, 100);

var t1 = new Date();
assert.throws(() => {
timers.call(test2, 30);
});
var t2 = new Date();
assert.greaterThan(t2 - t1, 90);
assert.lessThan(t2 - t1, 150);
});
});

require.main === module && test.run(console.DEBUG);

0 comments on commit b6d44ff

Please sign in to comment.
You can’t perform that action at this time.