Skip to content

Commit

Permalink
test: fix incorrect timers-promisified case
Browse files Browse the repository at this point in the history
PR-URL: #37425
Fixes: #37395
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
ttzztztz authored and targos committed Feb 28, 2021
1 parent 1408de7 commit f2aa305
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions test/parallel/test-timers-promisified.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,23 @@ process.on('multipleResolves', common.mustNotCall());
// Check that the timing is correct
let pre = false;
let post = false;
setPromiseTimeout(1).then(() => pre = true);
const iterable = setInterval(() => {}, 2);
const iterator = iterable[Symbol.asyncIterator]();

iterator.next().then(common.mustCall(() => {
assert.ok(pre, 'interval ran too early');
assert.ok(!post, 'interval ran too late');
return iterator.next();
})).then(common.mustCall(() => {
assert.ok(post, 'second interval ran too early');
return iterator.return();
}));

setPromiseTimeout(3).then(() => post = true);
const time_unit = 50;
Promise.all([
setPromiseTimeout(1).then(() => pre = true),
new Promise((res) => {
const iterable = timerPromises.setInterval(time_unit * 2);
const iterator = iterable[Symbol.asyncIterator]();

iterator.next().then(() => {
assert.ok(pre, 'interval ran too early');
assert.ok(!post, 'interval ran too late');
return iterator.next();
}).then(() => {
assert.ok(post, 'second interval ran too early');
return iterator.return();
}).then(res);
}),
setPromiseTimeout(time_unit * 3).then(() => post = true)
]).then(common.mustCall());
}

0 comments on commit f2aa305

Please sign in to comment.