1'use strict'; 2 3const common = require('../common'); 4 5const assert = require('assert'); 6 7{ 8 assert.strictEqual(process.getActiveResourcesInfo().filter( 9 (type) => type === 'Timeout').length, 0); 10 11 const timeout = setTimeout(common.mustCall(() => { 12 assert.strictEqual(process.getActiveResourcesInfo().filter( 13 (type) => type === 'Timeout').length, 1); 14 clearTimeout(timeout); 15 assert.strictEqual(process.getActiveResourcesInfo().filter( 16 (type) => type === 'Timeout').length, 0); 17 }), 0); 18 19 assert.strictEqual(process.getActiveResourcesInfo().filter( 20 (type) => type === 'Timeout').length, 1); 21} 22 23{ 24 assert.strictEqual(process.getActiveResourcesInfo().filter( 25 (type) => type === 'Immediate').length, 0); 26 27 const immediate = setImmediate(common.mustCall(() => { 28 // TODO(RaisinTen): Change this test to the following when the Immediate is 29 // destroyed and unrefed after the callback gets executed. 30 // assert.strictEqual(process.getActiveResourcesInfo().filter( 31 // (type) => type === 'Immediate').length, 1); 32 assert.strictEqual(process.getActiveResourcesInfo().filter( 33 (type) => type === 'Immediate').length, 0); 34 clearImmediate(immediate); 35 assert.strictEqual(process.getActiveResourcesInfo().filter( 36 (type) => type === 'Immediate').length, 0); 37 })); 38 39 assert.strictEqual(process.getActiveResourcesInfo().filter( 40 (type) => type === 'Immediate').length, 1); 41} 42