Permalink
Browse files

test: changed var to const, added strict equal checks

Changed var to const where appropriate. Substituted
assert.strictEqual for assert.equal for better type checks.

PR-URL: #8762
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
llkats authored and jasnell committed Sep 24, 2016
1 parent 927661f commit 52b6cfb6eb98ddb216c375074bf517ce581e8f0f
Showing with 19 additions and 14 deletions.
  1. +19 −14 test/parallel/test-fs-read-stream-fd-leak.js
@@ -1,17 +1,17 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
var openCount = 0;
var _fsopen = fs.open;
var _fsclose = fs.close;
const _fsopen = fs.open;
const _fsclose = fs.close;
var loopCount = 50;
var totalCheck = 50;
var emptyTxt = path.join(common.fixturesDir, 'empty.txt');
const loopCount = 50;
const totalCheck = 50;
const emptyTxt = path.join(common.fixturesDir, 'empty.txt');
fs.open = function() {
openCount++;
@@ -29,20 +29,25 @@ function testLeak(endFn, callback) {
var i = 0;
var check = 0;
var checkFunction = function() {
if (openCount != 0 && check < totalCheck) {
const checkFunction = function() {
if (openCount !== 0 && check < totalCheck) {
check++;
setTimeout(checkFunction, 100);
return;
}
assert.equal(0, openCount, 'no leaked file descriptors using ' +
endFn + '() (got ' + openCount + ')');
assert.strictEqual(
0,
openCount,
`no leaked file descriptors using ${endFn}() (got ${openCount})`
);
openCount = 0;
callback && setTimeout(callback, 100);
};
setInterval(function() {
var s = fs.createReadStream(emptyTxt);
const s = fs.createReadStream(emptyTxt);
s[endFn]();
if (++i === loopCount) {

0 comments on commit 52b6cfb

Please sign in to comment.