2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-12-23 16:02:12 -08:00
|
|
|
require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
2015-03-20 17:35:52 +01:00
|
|
|
|
|
|
|
function range(n) {
|
|
|
|
return 'x'.repeat(n + 1).split('').map(function(_, i) { return i; });
|
|
|
|
}
|
|
|
|
|
|
|
|
function timeout(nargs) {
|
2016-12-29 16:55:51 +00:00
|
|
|
const args = range(nargs);
|
2015-03-20 17:35:52 +01:00
|
|
|
setTimeout.apply(null, [callback, 1].concat(args));
|
|
|
|
|
|
|
|
function callback() {
|
2016-04-19 15:37:45 -07:00
|
|
|
assert.deepStrictEqual([].slice.call(arguments), args);
|
2015-03-20 17:35:52 +01:00
|
|
|
if (nargs < 128) timeout(nargs + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function interval(nargs) {
|
2016-12-29 16:55:51 +00:00
|
|
|
const args = range(nargs);
|
|
|
|
const timer = setTimeout.apply(null, [callback, 1].concat(args));
|
2015-03-20 17:35:52 +01:00
|
|
|
|
|
|
|
function callback() {
|
|
|
|
clearInterval(timer);
|
2016-04-19 15:37:45 -07:00
|
|
|
assert.deepStrictEqual([].slice.call(arguments), args);
|
2015-03-20 17:35:52 +01:00
|
|
|
if (nargs < 128) interval(nargs + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timeout(0);
|
|
|
|
interval(0);
|