mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 11:29:35 +00:00

common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
32 lines
697 B
JavaScript
32 lines
697 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
|
|
function range(n) {
|
|
return 'x'.repeat(n + 1).split('').map(function(_, i) { return i; });
|
|
}
|
|
|
|
function timeout(nargs) {
|
|
var args = range(nargs);
|
|
setTimeout.apply(null, [callback, 1].concat(args));
|
|
|
|
function callback() {
|
|
assert.deepEqual([].slice.call(arguments), args);
|
|
if (nargs < 128) timeout(nargs + 1);
|
|
}
|
|
}
|
|
|
|
function interval(nargs) {
|
|
var args = range(nargs);
|
|
var timer = setTimeout.apply(null, [callback, 1].concat(args));
|
|
|
|
function callback() {
|
|
clearInterval(timer);
|
|
assert.deepEqual([].slice.call(arguments), args);
|
|
if (nargs < 128) interval(nargs + 1);
|
|
}
|
|
}
|
|
|
|
timeout(0);
|
|
interval(0);
|