1'use strict'; 2require('../common'); 3const assert = require('assert'); 4 5function range(n) { 6 return 'x'.repeat(n + 1).split('').map(function(_, i) { return i; }); 7} 8 9function timeout(nargs) { 10 const args = range(nargs); 11 setTimeout.apply(null, [callback, 1].concat(args)); 12 13 function callback() { 14 assert.deepStrictEqual([].slice.call(arguments), args); 15 if (nargs < 128) timeout(nargs + 1); 16 } 17} 18 19function interval(nargs) { 20 const args = range(nargs); 21 const timer = setTimeout.apply(null, [callback, 1].concat(args)); 22 23 function callback() { 24 clearInterval(timer); 25 assert.deepStrictEqual([].slice.call(arguments), args); 26 if (nargs < 128) interval(nargs + 1); 27 } 28} 29 30timeout(0); 31interval(0); 32