node/test/parallel/test-timers-zero-timeout.js
cjihrig 4a408321d9 test: cleanup IIFE tests
A number of test files use IIFEs to separate distinct tests from
each other in the same file. The project has been moving toward
using block scopes and let/const in favor of IIFEs. This commit
moves IIFE tests to block scopes. Some additional cleanup such
as use of strictEqual() and common.mustCall() is also included.

PR-URL: https://github.com/nodejs/node/pull/7694
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-07-14 22:07:14 -04:00

33 lines
717 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
// https://github.com/joyent/node/issues/2079 - zero timeout drops extra args
{
setTimeout(common.mustCall(f), 0, 'foo', 'bar', 'baz');
setTimeout(function() {}, 0);
function f(a, b, c) {
assert.strictEqual(a, 'foo');
assert.strictEqual(b, 'bar');
assert.strictEqual(c, 'baz');
}
}
{
let ncalled = 0;
const iv = setInterval(f, 0, 'foo', 'bar', 'baz');
function f(a, b, c) {
assert.strictEqual(a, 'foo');
assert.strictEqual(b, 'bar');
assert.strictEqual(c, 'baz');
if (++ncalled == 3) clearTimeout(iv);
}
process.on('exit', function() {
assert.strictEqual(ncalled, 3);
});
}