From 74e7b3414570f5beea689a08df27dcfe613317d4 Mon Sep 17 00:00:00 2001 From: Lydia Kats Date: Wed, 28 Sep 2016 18:55:59 -0700 Subject: [PATCH] test: modernize syntax, add strict checks Changed `var` to `const`, strings to template literals, and assert.equal to assert.strictEqual where appropriate. PR-URL: https://github.com/nodejs/node/pull/8841 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel --- test/parallel/test-fs-readfile-pipe-large.js | 20 +++++++++---------- test/parallel/test-fs-readfile-pipe.js | 16 +++++++-------- .../test-fs-readfilesync-pipe-large.js | 20 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/parallel/test-fs-readfile-pipe-large.js b/test/parallel/test-fs-readfile-pipe-large.js index ba449695e4..1b1523cb13 100644 --- a/test/parallel/test-fs-readfile-pipe-large.js +++ b/test/parallel/test-fs-readfile-pipe-large.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); // simulate `cat readfile.js | node readfile.js` @@ -10,7 +10,7 @@ if (common.isWindows || common.isAix) { return; } -var fs = require('fs'); +const fs = require('fs'); if (process.argv[2] === 'child') { fs.readFile('/dev/stdin', function(er, data) { @@ -20,15 +20,15 @@ if (process.argv[2] === 'child') { return; } -var filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt'); -var dataExpected = new Array(1000000).join('a'); +const filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt'); +const dataExpected = new Array(1000000).join('a'); common.refreshTmpDir(); fs.writeFileSync(filename, dataExpected); -var exec = require('child_process').exec; -var f = JSON.stringify(__filename); -var node = JSON.stringify(process.execPath); -var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child'; +const exec = require('child_process').exec; +const f = JSON.stringify(__filename); +const node = JSON.stringify(process.execPath); +const cmd = `cat ${filename} | ${node} ${f} child`; exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) { if (err) console.error(err); assert(!err, 'it exits normally'); diff --git a/test/parallel/test-fs-readfile-pipe.js b/test/parallel/test-fs-readfile-pipe.js index 98841cbcb5..54fb1fbe10 100644 --- a/test/parallel/test-fs-readfile-pipe.js +++ b/test/parallel/test-fs-readfile-pipe.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // simulate `cat readfile.js | node readfile.js` @@ -9,9 +9,9 @@ if (common.isWindows || common.isAix) { return; } -var fs = require('fs'); +const fs = require('fs'); -var dataExpected = fs.readFileSync(__filename, 'utf8'); +const dataExpected = fs.readFileSync(__filename, 'utf8'); if (process.argv[2] === 'child') { fs.readFile('/dev/stdin', function(er, data) { @@ -21,10 +21,10 @@ if (process.argv[2] === 'child') { return; } -var exec = require('child_process').exec; -var f = JSON.stringify(__filename); -var node = JSON.stringify(process.execPath); -var cmd = 'cat ' + f + ' | ' + node + ' ' + f + ' child'; +const exec = require('child_process').exec; +const f = JSON.stringify(__filename); +const node = JSON.stringify(process.execPath); +const cmd = `cat ${f} | ${node} ${f} child`; exec(cmd, function(err, stdout, stderr) { if (err) console.error(err); assert(!err, 'it exits normally'); diff --git a/test/parallel/test-fs-readfilesync-pipe-large.js b/test/parallel/test-fs-readfilesync-pipe-large.js index fbb89e12ec..9108118b87 100644 --- a/test/parallel/test-fs-readfilesync-pipe-large.js +++ b/test/parallel/test-fs-readfilesync-pipe-large.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); // simulate `cat readfile.js | node readfile.js` @@ -10,22 +10,22 @@ if (common.isWindows || common.isAix) { return; } -var fs = require('fs'); +const fs = require('fs'); if (process.argv[2] === 'child') { process.stdout.write(fs.readFileSync('/dev/stdin', 'utf8')); return; } -var filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt'); -var dataExpected = new Array(1000000).join('a'); +const filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt'); +const dataExpected = new Array(1000000).join('a'); common.refreshTmpDir(); fs.writeFileSync(filename, dataExpected); -var exec = require('child_process').exec; -var f = JSON.stringify(__filename); -var node = JSON.stringify(process.execPath); -var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child'; +const exec = require('child_process').exec; +const f = JSON.stringify(__filename); +const node = JSON.stringify(process.execPath); +const cmd = `cat ${filename} | ${node} ${f} child`; exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) { if (err) console.error(err); assert(!err, 'it exits normally');