Permalink
Browse files

test: use const for all require() calls

PR-URL: #10550
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
cjihrig committed Dec 30, 2016
1 parent 1605a2e commit ff1efa60878d8353e1b8e36684a786bdf57963fb
Showing 605 changed files with 1,573 additions and 1,552 deletions.
@@ -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) {
@@ -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());
@@ -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());
@@ -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');
@@ -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.
@@ -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;
@@ -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');
@@ -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 = [
@@ -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');
@@ -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;
@@ -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');
@@ -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');
@@ -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);
@@ -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+'),
@@ -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;
@@ -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({
@@ -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: {
@@ -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,
@@ -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');
@@ -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');
@@ -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]);
@@ -1,4 +1,4 @@
var c = require('./b/c');
const c = require('./b/c');
console.error('load fixtures/a.js');
@@ -1,4 +1,4 @@
var c = require('./b/c');
const c = require('./b/c');
console.error('load fixtures/a.js');
@@ -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);
@@ -1,4 +1,4 @@
var mod = require('./mod.js');
const mod = require('./mod.js');
mod.hello();
mod.hello();
debugger;
@@ -1,4 +1,4 @@
var assert = require('assert');
const assert = require('assert');
function onmessage(m) {
console.log('CHILD got message:', m);
@@ -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) {
@@ -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) {
@@ -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
@@ -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]);
@@ -1,4 +1,4 @@
var root = require('./../root');
const root = require('./../root');
exports.hello = function() {
return root.calledFromFoo();
@@ -1,4 +1,4 @@
var foo = exports.foo = require('./folder/foo');
const foo = exports.foo = require('./folder/foo');
exports.hello = 'hello';
exports.sayHello = function() {
@@ -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');
@@ -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');
@@ -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();
@@ -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);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -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');
@@ -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');
@@ -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]));
@@ -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.
@@ -1,4 +1,4 @@
var assert = require('assert');
const assert = require('assert');
var n = parseInt(process.argv[2]);
Oops, something went wrong.

0 comments on commit ff1efa6

Please sign in to comment.