0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/parallel/test-timers-args.js
Rich Trott a7335bd1f0 test,benchmark: use deepStrictEqual()
In preparation for a lint rule that will enforce
assert.deepStrictEqual() over assert.deepEqual(), change tests and
benchmarks accordingly. For tests and benchmarks that are testing or
benchmarking assert.deepEqual() itself, apply a comment to ignore the
upcoming rule.

PR-URL: https://github.com/nodejs/node/pull/6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-22 14:38:09 -07:00

32 lines
709 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.deepStrictEqual([].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.deepStrictEqual([].slice.call(arguments), args);
if (nargs < 128) interval(nargs + 1);
}
}
timeout(0);
interval(0);