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 <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
Lydia Kats 2016-09-28 18:55:59 -07:00 committed by Jeremiah Senkpiel
parent cd5a4c157c
commit b838e5ff86
3 changed files with 28 additions and 28 deletions

View File

@ -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');

View File

@ -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');

View File

@ -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');