11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci{
81cb0ef41Sopenharmony_ci  assert.strictEqual(process.getActiveResourcesInfo().filter(
91cb0ef41Sopenharmony_ci    (type) => type === 'Timeout').length, 0);
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci  const timeout = setTimeout(common.mustCall(() => {
121cb0ef41Sopenharmony_ci    assert.strictEqual(process.getActiveResourcesInfo().filter(
131cb0ef41Sopenharmony_ci      (type) => type === 'Timeout').length, 1);
141cb0ef41Sopenharmony_ci    clearTimeout(timeout);
151cb0ef41Sopenharmony_ci    assert.strictEqual(process.getActiveResourcesInfo().filter(
161cb0ef41Sopenharmony_ci      (type) => type === 'Timeout').length, 0);
171cb0ef41Sopenharmony_ci  }), 0);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  assert.strictEqual(process.getActiveResourcesInfo().filter(
201cb0ef41Sopenharmony_ci    (type) => type === 'Timeout').length, 1);
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci{
241cb0ef41Sopenharmony_ci  assert.strictEqual(process.getActiveResourcesInfo().filter(
251cb0ef41Sopenharmony_ci    (type) => type === 'Immediate').length, 0);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci  const immediate = setImmediate(common.mustCall(() => {
281cb0ef41Sopenharmony_ci    // TODO(RaisinTen): Change this test to the following when the Immediate is
291cb0ef41Sopenharmony_ci    // destroyed and unrefed after the callback gets executed.
301cb0ef41Sopenharmony_ci    // assert.strictEqual(process.getActiveResourcesInfo().filter(
311cb0ef41Sopenharmony_ci    //   (type) => type === 'Immediate').length, 1);
321cb0ef41Sopenharmony_ci    assert.strictEqual(process.getActiveResourcesInfo().filter(
331cb0ef41Sopenharmony_ci      (type) => type === 'Immediate').length, 0);
341cb0ef41Sopenharmony_ci    clearImmediate(immediate);
351cb0ef41Sopenharmony_ci    assert.strictEqual(process.getActiveResourcesInfo().filter(
361cb0ef41Sopenharmony_ci      (type) => type === 'Immediate').length, 0);
371cb0ef41Sopenharmony_ci  }));
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci  assert.strictEqual(process.getActiveResourcesInfo().filter(
401cb0ef41Sopenharmony_ci    (type) => type === 'Immediate').length, 1);
411cb0ef41Sopenharmony_ci}
42