mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 13:11:36 +00:00

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>
33 lines
717 B
JavaScript
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);
|
|
});
|
|
}
|