xref: /third_party/node/test/parallel/test-timers-destroyed.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// We don't really care about the calling results here.
71cb0ef41Sopenharmony_ci// So, this makes the test less fragile.
81cb0ef41Sopenharmony_ciconst noop = () => {};
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst t1 = setTimeout(common.mustNotCall(), 1);
111cb0ef41Sopenharmony_ciconst t2 = setTimeout(common.mustCall(), 1);
121cb0ef41Sopenharmony_ciconst i1 = setInterval(common.mustNotCall(), 1);
131cb0ef41Sopenharmony_ciconst i2 = setInterval(noop, 1);
141cb0ef41Sopenharmony_cii2.unref();
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// Keep process alive for i2 to call once due to timer ordering.
171cb0ef41Sopenharmony_cisetTimeout(common.mustCall(), 1);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciclearTimeout(t1);
201cb0ef41Sopenharmony_ciclearInterval(i1);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciprocess.on('exit', () => {
231cb0ef41Sopenharmony_ci  assert.strictEqual(t1._destroyed, true);
241cb0ef41Sopenharmony_ci  assert.strictEqual(t2._destroyed, true);
251cb0ef41Sopenharmony_ci  assert.strictEqual(i1._destroyed, true);
261cb0ef41Sopenharmony_ci  assert.strictEqual(i2._destroyed, false);
271cb0ef41Sopenharmony_ci});
28

Indexes created Thu Nov 07 10:32:03 CST 2024