1// Flags: --expose-internals 2'use strict'; 3 4const common = require('../common'); 5const { sleep } = require('internal/util'); 6 7// This test verifies that the next tick queue runs after each 8// individual Timeout, as well as each individual Immediate. 9 10setTimeout(common.mustCall(() => { 11 process.nextTick(() => { 12 // Confirm that clearing Timeouts from a next tick doesn't explode. 13 clearTimeout(t2); 14 clearTimeout(t3); 15 }); 16}), 1); 17const t2 = setTimeout(common.mustNotCall(), 1); 18const t3 = setTimeout(common.mustNotCall(), 1); 19setTimeout(common.mustCall(), 1); 20 21sleep(5); 22 23setImmediate(common.mustCall(() => { 24 process.nextTick(() => { 25 // Confirm that clearing Immediates from a next tick doesn't explode. 26 clearImmediate(i2); 27 clearImmediate(i3); 28 }); 29})); 30const i2 = setImmediate(common.mustNotCall()); 31const i3 = setImmediate(common.mustNotCall()); 32setImmediate(common.mustCall()); 33