node/test/parallel/test-timers-max-duration-warning.js
Yagiz Nizipli 5d7091f1bc
timers: set several methods EOL
PR-URL: https://github.com/nodejs/node/pull/56966
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-02-10 21:09:41 +00:00

33 lines
792 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
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);
}, 2));
{
const timeout = setTimeout(timerNotCanceled, OVERFLOW);
clearTimeout(timeout);
}
{
const interval = setInterval(timerNotCanceled, OVERFLOW);
clearInterval(interval);
}