Overlooked when landing the respective PRs. PR-URL: https://github.com/nodejs/node/pull/18564 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
42 lines
971 B
JavaScript
42 lines
971 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const timers = require('timers');
|
|
|
|
const OVERFLOW = Math.pow(2, 31); // TIMEOUT_MAX is 2^31-1
|
|
|
|
function timerNotCanceled() {
|
|
assert.fail('Timer should be canceled');
|
|
}
|
|
|
|
process.on('warning', common.mustCall((warning) => {
|
|
if (warning.name === 'DeprecationWarning') return;
|
|
|
|
const lines = warning.message.split('\n');
|
|
|
|
assert.strictEqual(warning.name, 'TimeoutOverflowWarning');
|
|
assert.strictEqual(lines[0], `${OVERFLOW} does not fit into a 32-bit signed` +
|
|
' integer.');
|
|
assert.strictEqual(lines.length, 2);
|
|
}, 5));
|
|
|
|
|
|
{
|
|
const timeout = setTimeout(timerNotCanceled, OVERFLOW);
|
|
clearTimeout(timeout);
|
|
}
|
|
|
|
{
|
|
const interval = setInterval(timerNotCanceled, OVERFLOW);
|
|
clearInterval(interval);
|
|
}
|
|
|
|
{
|
|
const timer = {
|
|
_onTimeout: timerNotCanceled
|
|
};
|
|
timers.enroll(timer, OVERFLOW);
|
|
timers.active(timer);
|
|
timers.unenroll(timer);
|
|
}
|