Skip to content

Commit

Permalink
test: use const for all require() calls
Browse files Browse the repository at this point in the history
PR-URL: nodejs#10550
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig authored and italoacasas committed Jan 19, 2017
1 parent f3a466a commit 10abc52
Show file tree
Hide file tree
Showing 605 changed files with 1,573 additions and 1,552 deletions.
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
var assert = require('assert');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);

binding(5, common.mustCall(function(err, val) {
Expand Down
2 changes: 1 addition & 1 deletion test/addons/hello-world-function-export/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
var assert = require('assert');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
assert.strictEqual(binding(), 'world');
console.log('binding.hello() =', binding());
2 changes: 1 addition & 1 deletion test/addons/hello-world/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
var assert = require('assert');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
assert.strictEqual(binding.hello(), 'world');
console.log('binding.hello() =', binding.hello());
2 changes: 1 addition & 1 deletion test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ var contents = fs.readFileSync(addonPath);
fs.writeFileSync(addonDestinationPath, contents);

// Attempt to load at long path destination
var addon = require(addonDestinationPath);
const addon = require(addonDestinationPath);
assert.notEqual(addon, null);
assert.strictEqual(addon.hello(), 'world');
10 changes: 5 additions & 5 deletions test/addons/repl-domain-abort/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
var common = require('../../common');
var assert = require('assert');
var repl = require('repl');
var stream = require('stream');
var path = require('path');
const common = require('../../common');
const assert = require('assert');
const repl = require('repl');
const stream = require('stream');
const path = require('path');
var buildType = process.config.target_defaults.default_configuration;
var buildPath = path.join(__dirname, 'build', buildType, 'binding');
// On Windows, escape backslashes in the path before passing it to REPL.
Expand Down
4 changes: 2 additions & 2 deletions test/debugger/helper-debugger-repl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
const assert = require('assert');
const spawn = require('child_process').spawn;

process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var port = common.PORT;
Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-repl-break-in-module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
require('../common');
var repl = require('./helper-debugger-repl.js');
const repl = require('./helper-debugger-repl.js');

repl.startDebugger('break-in-module/main.js');

Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-repl-restart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
require('../common');
var repl = require('./helper-debugger-repl.js');
const repl = require('./helper-debugger-repl.js');

repl.startDebugger('breakpoints.js');
var linesWithBreakpoint = [
Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-repl-term.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require('../common');
process.env.NODE_FORCE_READLINE = 1;

var repl = require('./helper-debugger-repl.js');
const repl = require('./helper-debugger-repl.js');

repl.startDebugger('breakpoints.js');

Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-repl-utf8.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
var common = require('../common');
const common = require('../common');
var script = common.fixturesDir + '/breakpoints_utf8.js';
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;

Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debugger-repl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
require('../common');
var repl = require('./helper-debugger-repl.js');
const repl = require('./helper-debugger-repl.js');

repl.startDebugger('breakpoints.js');

Expand Down
10 changes: 5 additions & 5 deletions test/disabled/test-debug-brk-file.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var path = require('path');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
const path = require('path');
const net = require('net');

var isDone = false;
var targetPath = path.resolve(common.fixturesDir, 'debug-target.js');
Expand Down
2 changes: 1 addition & 1 deletion test/disabled/test-dgram-send-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const common = require('../common');
var ITERATIONS = 1000;

var assert = require('assert'),
const assert = require('assert'),
dgram = require('dgram');

var buf = Buffer.alloc(1024, 42);
Expand Down
6 changes: 3 additions & 3 deletions test/disabled/test-fs-largefile.js
Original file line number Diff line number Diff line change
@@ -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'),
fs = require('fs'),
filepath = path.join(common.tmpDir, 'large.txt'),
fd = fs.openSync(filepath, 'w+'),
Expand Down
6 changes: 3 additions & 3 deletions test/disabled/test-http-abort-stream-end.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var http = require('http');
const http = require('http');

var maxSize = 1024;
var size = 0;
Expand Down
4 changes: 2 additions & 2 deletions test/disabled/test-https-loop-to-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Tested on node 0.5.0-pre commit 9851574


var common = require('../common');
var https = require('https');
const common = require('../common');
const https = require('https');

for (var i = 0; i < 10; ++i) {
https.get({
Expand Down
6 changes: 3 additions & 3 deletions test/disabled/test-readline.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
// Yet another use-case for require('tty').spawn ?
var common = require('../common');
var assert = require('assert');
var readline = require('readline');
const common = require('../common');
const assert = require('assert');
const readline = require('readline');

var key = {
xterm: {
Expand Down
14 changes: 7 additions & 7 deletions test/disabled/test-sendfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
// seen in a response yet. This is intended to ensure that all blobs
// sent out have been relayed back to us.

var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var buffer = require('buffer');
var child_process = require('child_process');
var fs = require('fs');
var net = require('net');
const buffer = require('buffer');
const child_process = require('child_process');
const fs = require('fs');
const net = require('net');
var netBinding = process.binding('net');
var path = require('path');
const path = require('path');

var DATA = {
'ppid' : process.pid,
Expand Down
4 changes: 2 additions & 2 deletions test/disabled/test-setuidgid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
// Requires special privileges
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var oldgid = process.getgid();
process.setgid('nobody');
Expand Down
12 changes: 6 additions & 6 deletions test/disabled/tls_server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var util = require('util');
var net = require('net');
var fs = require('fs');
var crypto = require('crypto');
const util = require('util');
const net = require('net');
const fs = require('fs');
const crypto = require('crypto');

var keyPem = fs.readFileSync(common.fixturesDir + '/cert.pem');
var certPem = fs.readFileSync(common.fixturesDir + '/cert.pem');
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/GH-892-request.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Called by test/pummel/test-regress-GH-892.js

var https = require('https');
var fs = require('fs');
var assert = require('assert');
const https = require('https');
const fs = require('fs');
const assert = require('assert');

var PORT = parseInt(process.argv[2]);
var bytesExpected = parseInt(process.argv[3]);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/a.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var c = require('./b/c');
const c = require('./b/c');

console.error('load fixtures/a.js');

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/a1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var c = require('./b/c');
const c = require('./b/c');

console.error('load fixtures/a.js');

Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/b/c.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var d = require('./d');
const d = require('./d');

var assert = require('assert');
const assert = require('assert');

var package = require('./package');
const package = require('./package');

assert.equal('world', package.hello);

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/break-in-module/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var mod = require('./mod.js');
const mod = require('./mod.js');
mod.hello();
mod.hello();
debugger;
2 changes: 1 addition & 1 deletion test/fixtures/child-process-spawn-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('assert');
const assert = require('assert');

function onmessage(m) {
console.log('CHILD got message:', m);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/child_process_should_emit_error.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var exec = require('child_process').exec;
const exec = require('child_process').exec;

[0, 1].forEach(function(i) {
exec('ls', function(err, stdout, stderr) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cluster-preload-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var cluster = require('cluster');
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork(); // one child
cluster.on('exit', function(worker, code, signal) {
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/cluster-preload.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var assert = require('assert');
const assert = require('assert');

// https://github.com/nodejs/node/issues/1803
// this module is used as a preload module. It should have a parent with the
// module search paths initialized from the current working directory
assert.ok(module.parent);
var expectedPaths = require('module')._nodeModulePaths(process.cwd());
const expectedPaths = require('module')._nodeModulePaths(process.cwd());
assert.deepEqual(module.parent.paths, expectedPaths);

var cluster = require('cluster');
const cluster = require('cluster');
cluster.isMaster || process.exit(42 + cluster.worker.id); // +42 to distinguish
// from exit(1) for other random reasons
2 changes: 1 addition & 1 deletion test/fixtures/create-file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs');
const fs = require('fs');

var file_name = process.argv[2];
var file_size = parseInt(process.argv[3]);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cycles/folder/foo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var root = require('./../root');
const root = require('./../root');

exports.hello = function() {
return root.calledFromFoo();
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cycles/root.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var foo = exports.foo = require('./folder/foo');
const foo = exports.foo = require('./folder/foo');

exports.hello = 'hello';
exports.sayHello = function() {
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/echo-close-check.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var common = require('../common');
var assert = require('assert');
var net = require('net');
var fs = require('fs');
const common = require('../common');
const assert = require('assert');
const net = require('net');
const fs = require('fs');

process.stdout.write('hello world\r\n');

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/echo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

process.stdout.write('hello world\r\n');

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/listen-on-socket-and-exit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// child process that listens on a socket, allows testing of an EADDRINUSE condition

var common = require('../common');
var net = require('net');
const common = require('../common');
const net = require('net');

common.refreshTmpDir();

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/module-require/parent/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var child = require('../child');
const child = require('../child');
//console.log(child.module.require, child.module);
console.log(child.module.require('target'));
console.log(child.loaded);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/node_modules/baz/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/node_modules/foo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/not-main-module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('assert');
const assert = require('assert');
assert.notEqual(module, require.main, 'require.main should not == module');
assert.notEqual(module, process.mainModule,
'process.mainModule should not === module');
2 changes: 1 addition & 1 deletion test/fixtures/parent-process-nonpersistent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var spawn = require('child_process').spawn,
const spawn = require('child_process').spawn,
path = require('path'),
childPath = path.join(__dirname, 'child-process-persistent.js');

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/path-resolve.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tests resolving a path in the context of a spawned process.
// See https://github.com/nodejs/node/issues/7215
var path = require('path');
const path = require('path');
console.log(path.resolve(process.argv[2]));
2 changes: 1 addition & 1 deletion test/fixtures/path.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This is actually more a fixture than a test. It is used to make
var common = require('../common');
const common = require('../common');
// sure that require('./path') and require('path') do different things.
// It has to be in the same directory as the test 'test-module-loading.js'
// and it has to have the same name as an internal module.
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/print-chars-from-buffer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('assert');
const assert = require('assert');

var n = parseInt(process.argv[2]);

Expand Down
Loading

0 comments on commit 10abc52

Please sign in to comment.