mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
729 B
28 lines
729 B
'use strict';
|
|
/*
|
|
* This test is a regression test for joyent/node#8900.
|
|
*/
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const TEST_DURATION = common.platformTimeout(100);
|
|
const N = 5;
|
|
var nbIntervalFired = 0;
|
|
|
|
const keepOpen = setTimeout(() => {
|
|
console.error('[FAIL] Interval fired %d/%d times.', nbIntervalFired, N);
|
|
throw new Error('Test timed out. keepOpen was not canceled.');
|
|
}, TEST_DURATION);
|
|
|
|
const timer = setInterval(() => {
|
|
++nbIntervalFired;
|
|
if (nbIntervalFired === N) {
|
|
clearInterval(timer);
|
|
timer._onTimeout = () => {
|
|
throw new Error('Unrefd interval fired after being cleared.');
|
|
};
|
|
setImmediate(() => clearTimeout(keepOpen));
|
|
}
|
|
}, 1);
|
|
|
|
timer.unref();
|
|
|