node/test/parallel/test-timers-dispose.js
Moshe Atlow 56b8de1699
timers: support Symbol.dispose
PR-URL: https://github.com/nodejs/node/pull/48633
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2023-07-05 13:39:38 +00:00

19 lines
509 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const timer = setTimeout(common.mustNotCall(), 10);
const interval = setInterval(common.mustNotCall(), 10);
const immediate = setImmediate(common.mustNotCall());
timer[Symbol.dispose]();
interval[Symbol.dispose]();
immediate[Symbol.dispose]();
process.on('exit', () => {
assert.strictEqual(timer._destroyed, true);
assert.strictEqual(interval._destroyed, true);
assert.strictEqual(immediate._destroyed, true);
});