11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci[ 71cb0ef41Sopenharmony_ci setTimeout(common.mustNotCall(), 1), 81cb0ef41Sopenharmony_ci setInterval(common.mustNotCall(), 1), 91cb0ef41Sopenharmony_ci].forEach((timeout) => { 101cb0ef41Sopenharmony_ci assert.strictEqual(Number.isNaN(+timeout), false); 111cb0ef41Sopenharmony_ci assert.strictEqual(+timeout, timeout[Symbol.toPrimitive]()); 121cb0ef41Sopenharmony_ci assert.strictEqual(`${timeout}`, timeout[Symbol.toPrimitive]().toString()); 131cb0ef41Sopenharmony_ci assert.deepStrictEqual(Object.keys({ [timeout]: timeout }), [`${timeout}`]); 141cb0ef41Sopenharmony_ci clearTimeout(+timeout); 151cb0ef41Sopenharmony_ci}); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci{ 181cb0ef41Sopenharmony_ci // Check that clearTimeout works with number id. 191cb0ef41Sopenharmony_ci const timeout = setTimeout(common.mustNotCall(), 1); 201cb0ef41Sopenharmony_ci const id = +timeout; 211cb0ef41Sopenharmony_ci clearTimeout(id); 221cb0ef41Sopenharmony_ci} 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci{ 251cb0ef41Sopenharmony_ci // Check that clearTimeout works with string id. 261cb0ef41Sopenharmony_ci const timeout = setTimeout(common.mustNotCall(), 1); 271cb0ef41Sopenharmony_ci const id = `${timeout}`; 281cb0ef41Sopenharmony_ci clearTimeout(id); 291cb0ef41Sopenharmony_ci} 30