mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
aa363c49ea
This commit replaces common.busyLoop() with sleep(). PR-URL: https://github.com/nodejs/node/pull/30787 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
33 lines
909 B
JavaScript
33 lines
909 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { sleep } = require('internal/util');
|
|
|
|
// This test verifies that the next tick queue runs after each
|
|
// individual Timeout, as well as each individual Immediate.
|
|
|
|
setTimeout(common.mustCall(() => {
|
|
process.nextTick(() => {
|
|
// Confirm that clearing Timeouts from a next tick doesn't explode.
|
|
clearTimeout(t2);
|
|
clearTimeout(t3);
|
|
});
|
|
}), 1);
|
|
const t2 = setTimeout(common.mustNotCall(), 1);
|
|
const t3 = setTimeout(common.mustNotCall(), 1);
|
|
setTimeout(common.mustCall(), 1);
|
|
|
|
sleep(5);
|
|
|
|
setImmediate(common.mustCall(() => {
|
|
process.nextTick(() => {
|
|
// Confirm that clearing Immediates from a next tick doesn't explode.
|
|
clearImmediate(i2);
|
|
clearImmediate(i3);
|
|
});
|
|
}));
|
|
const i2 = setImmediate(common.mustNotCall());
|
|
const i3 = setImmediate(common.mustNotCall());
|
|
setImmediate(common.mustCall());
|