0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/sequential/test-timers-block-eventloop.js
cjihrig aa363c49ea
test: remove common.busyLoop()
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>
2019-12-06 22:03:00 -05:00

21 lines
400 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const { sleep } = require('internal/util');
let called = false;
const t1 = setInterval(() => {
assert(!called);
called = true;
setImmediate(common.mustCall(() => {
clearInterval(t1);
clearInterval(t2);
}));
}, 10);
const t2 = setInterval(() => {
sleep(20);
}, 10);