mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
b5ec47e941
Clean up test-timers-immediate. Use of `let` also requires a tweak to ESLint rules (but it's one that we should do as timers is pretty much the reason it exists). PR-URL: https://github.com/nodejs/node/pull/8857 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
34 lines
755 B
JavaScript
34 lines
755 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
let immediateB;
|
|
let immediateC;
|
|
let immediateD;
|
|
|
|
let mainFinished = false;
|
|
|
|
setImmediate(common.mustCall(function() {
|
|
assert.strictEqual(mainFinished, true);
|
|
clearImmediate(immediateB);
|
|
}));
|
|
|
|
immediateB = setImmediate(function() {
|
|
common.fail('this immediate should not run');
|
|
});
|
|
|
|
setImmediate(function(x, y, z) {
|
|
immediateC = [x, y, z];
|
|
}, 1, 2, 3);
|
|
|
|
setImmediate(function(x, y, z, a, b) {
|
|
immediateD = [x, y, z, a, b];
|
|
}, 1, 2, 3, 4, 5);
|
|
|
|
process.on('exit', function() {
|
|
assert.deepStrictEqual(immediateC, [1, 2, 3], 'immediateC args should match');
|
|
assert.deepStrictEqual(immediateD, [1, 2, 3, 4, 5], '5 args should match');
|
|
});
|
|
|
|
mainFinished = true;
|