From 6ba8aa963e63a415d3d349c357b56da80d0b13da Mon Sep 17 00:00:00 2001 From: Lydia Katsamberis Date: Sat, 24 Sep 2016 13:58:24 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/8762 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Myles Borins Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-fs-read-stream-fd-leak.js | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-fs-read-stream-fd-leak.js b/test/parallel/test-fs-read-stream-fd-leak.js index bac7d5c12166e7..45847270097348 100644 --- a/test/parallel/test-fs-read-stream-fd-leak.js +++ b/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) {