Skip to content

Commit 6ba8aa9

Browse files
llkatsFishrock123
authored andcommitted
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>
1 parent 81ed50c commit 6ba8aa9

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

test/parallel/test-fs-read-stream-fd-leak.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22

3-
var common = require('../common');
4-
var assert = require('assert');
5-
var fs = require('fs');
6-
var path = require('path');
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const fs = require('fs');
6+
const path = require('path');
77

88
var openCount = 0;
9-
var _fsopen = fs.open;
10-
var _fsclose = fs.close;
9+
const _fsopen = fs.open;
10+
const _fsclose = fs.close;
1111

12-
var loopCount = 50;
13-
var totalCheck = 50;
14-
var emptyTxt = path.join(common.fixturesDir, 'empty.txt');
12+
const loopCount = 50;
13+
const totalCheck = 50;
14+
const emptyTxt = path.join(common.fixturesDir, 'empty.txt');
1515

1616
fs.open = function() {
1717
openCount++;
@@ -29,20 +29,25 @@ function testLeak(endFn, callback) {
2929
var i = 0;
3030
var check = 0;
3131

32-
var checkFunction = function() {
33-
if (openCount != 0 && check < totalCheck) {
32+
const checkFunction = function() {
33+
if (openCount !== 0 && check < totalCheck) {
3434
check++;
3535
setTimeout(checkFunction, 100);
3636
return;
3737
}
38-
assert.equal(0, openCount, 'no leaked file descriptors using ' +
39-
endFn + '() (got ' + openCount + ')');
38+
39+
assert.strictEqual(
40+
0,
41+
openCount,
42+
`no leaked file descriptors using ${endFn}() (got ${openCount})`
43+
);
44+
4045
openCount = 0;
4146
callback && setTimeout(callback, 100);
4247
};
4348

4449
setInterval(function() {
45-
var s = fs.createReadStream(emptyTxt);
50+
const s = fs.createReadStream(emptyTxt);
4651
s[endFn]();
4752

4853
if (++i === loopCount) {

0 commit comments

Comments
 (0)