Skip to content

Commit

Permalink
test: clean up test-timers-immediate
Browse files Browse the repository at this point in the history
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: #8857
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Trott authored and jasnell committed Oct 6, 2016
1 parent c5643a8 commit e0d3d74
Showing 2 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ rules:
no-dupe-class-members: 2
no-new-symbol: 2
no-this-before-super: 2
prefer-const: 2
prefer-const: [2, {ignoreReadBeforeAssign: true}]
rest-spread-spacing: 2
template-curly-spacing: 2

35 changes: 15 additions & 20 deletions test/parallel/test-timers-immediate.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
'use strict';
require('../common');
var assert = require('assert');

let immediateA = false;
let immediateB = false;
let immediateC = [];
let immediateD = [];

setImmediate(function() {
try {
immediateA = process.hrtime(before);
} catch (e) {
console.log('failed to get hrtime with offset');
}
clearImmediate(immediateB);
});
const common = require('../common');
const assert = require('assert');

let immediateB;
let immediateC;
let immediateD;

const before = process.hrtime();
let mainFinished = false;

setImmediate(common.mustCall(function() {
assert.strictEqual(mainFinished, true);
clearImmediate(immediateB);
}));

immediateB = setImmediate(function() {
immediateB = true;
common.fail('this immediate should not run');
});

setImmediate(function(x, y, z) {
@@ -31,8 +26,8 @@ setImmediate(function(x, y, z, a, b) {
}, 1, 2, 3, 4, 5);

process.on('exit', function() {
assert.ok(immediateA, 'Immediate should happen after normal execution');
assert.notStrictEqual(immediateB, true, 'immediateB should not fire');
assert.deepStrictEqual(immediateC, [1, 2, 3], 'immediateC args should match');
assert.deepStrictEqual(immediateD, [1, 2, 3, 4, 5], '5 args should match');
});

mainFinished = true;

0 comments on commit e0d3d74

Please sign in to comment.