diff options
author | Gibson Fahnestock <gib@uk.ibm.com> | 2017-01-08 13:19:00 +0000 |
---|---|---|
committer | Gibson Fahnestock <gib@uk.ibm.com> | 2017-01-11 11:43:52 +0000 |
commit | 7a0e462f9facfff8ccd7b37eb5b65db1c2b2f55f (patch) | |
tree | a971102d320e17e6cb3d00c48fe708b2b86c8136 /test/sequential | |
parent | 1ef401ce92d6195878b9d041cc969612628f5852 (diff) | |
download | android-node-v8-7a0e462f9facfff8ccd7b37eb5b65db1c2b2f55f.tar.gz android-node-v8-7a0e462f9facfff8ccd7b37eb5b65db1c2b2f55f.tar.bz2 android-node-v8-7a0e462f9facfff8ccd7b37eb5b65db1c2b2f55f.zip |
test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.
PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'test/sequential')
-rw-r--r-- | test/sequential/test-child-process-execsync.js | 23 | ||||
-rw-r--r-- | test/sequential/test-debugger-debug-brk.js | 4 | ||||
-rw-r--r-- | test/sequential/test-deprecation-flags.js | 2 | ||||
-rw-r--r-- | test/sequential/test-http-regr-gh-2928.js | 8 | ||||
-rw-r--r-- | test/sequential/test-module-loading.js | 8 | ||||
-rw-r--r-- | test/sequential/test-net-GH-5504.js | 10 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-1697.js | 10 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-1726.js | 6 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-4015.js | 4 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-4027.js | 2 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-784.js | 16 | ||||
-rw-r--r-- | test/sequential/test-regress-GH-877.js | 20 | ||||
-rw-r--r-- | test/sequential/test-repl-timeout-throw.js | 6 | ||||
-rw-r--r-- | test/sequential/test-require-cache-without-stat.js | 10 | ||||
-rw-r--r-- | test/sequential/test-stream2-fs.js | 12 | ||||
-rw-r--r-- | test/sequential/test-stream2-stderr-sync.js | 10 | ||||
-rw-r--r-- | test/sequential/test-timers-blocking-callback.js | 6 | ||||
-rw-r--r-- | test/sequential/test-vm-timeout-rethrow.js | 12 |
18 files changed, 85 insertions, 84 deletions
diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 710137e419..fd9970db7d 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -5,12 +5,12 @@ const assert = require('assert'); const execSync = require('child_process').execSync; const execFileSync = require('child_process').execFileSync; -var TIMER = 200; -var SLEEP = 2000; +const TIMER = 200; +const SLEEP = 2000; -var start = Date.now(); -var err; -var caught = false; +const start = Date.now(); +let err; +let caught = false; // Verify that stderr is not accessed when a bad shell is used assert.throws( @@ -24,9 +24,10 @@ assert.throws( 'execFileSync did not throw the expected exception!' ); +let cmd, ret; try { - var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; - var ret = execSync(cmd, {timeout: TIMER}); + cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; + ret = execSync(cmd, {timeout: TIMER}); } catch (e) { caught = true; assert.strictEqual(e.errno, 'ETIMEDOUT'); @@ -34,7 +35,7 @@ try { } finally { assert.strictEqual(ret, undefined, 'we should not have a return value'); assert.strictEqual(caught, true, 'execSync should throw'); - var end = Date.now() - start; + const end = Date.now() - start; assert(end < SLEEP); assert(err.status > 128 || err.signal); } @@ -43,8 +44,8 @@ assert.throws(function() { execSync('iamabadcommand'); }, /Command failed: iamabadcommand/); -var msg = 'foobar'; -var msgBuf = Buffer.from(msg + '\n'); +const msg = 'foobar'; +const msgBuf = Buffer.from(msg + '\n'); // console.log ends every line with just '\n', even on Windows. @@ -59,7 +60,7 @@ ret = execSync(cmd, { encoding: 'utf8' }); assert.strictEqual(ret, msg + '\n', 'execSync encoding result should match'); -var args = [ +const args = [ '-e', `console.log("${msg}");` ]; diff --git a/test/sequential/test-debugger-debug-brk.js b/test/sequential/test-debugger-debug-brk.js index 5454aaa08a..f04af4544f 100644 --- a/test/sequential/test-debugger-debug-brk.js +++ b/test/sequential/test-debugger-debug-brk.js @@ -3,14 +3,14 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -var script = common.fixturesDir + '/empty.js'; +const script = common.fixturesDir + '/empty.js'; function fail() { assert(0); // `node --debug-brk script.js` should not quit } function test(arg) { - var child = spawn(process.execPath, [arg, script]); + const child = spawn(process.execPath, [arg, script]); child.on('exit', fail); // give node time to start up the debugger diff --git a/test/sequential/test-deprecation-flags.js b/test/sequential/test-deprecation-flags.js index e9f5ee673d..eb5c1a3ae6 100644 --- a/test/sequential/test-deprecation-flags.js +++ b/test/sequential/test-deprecation-flags.js @@ -38,7 +38,7 @@ execFile(node, traceDep, function(er, stdout, stderr) { console.error('--trace-deprecation: show stack'); assert.equal(er, null); assert.equal(stdout, ''); - var stack = stderr.trim().split('\n'); + const stack = stderr.trim().split('\n'); // just check the top and bottom. assert(/util.debug is deprecated. Use console.error instead./.test(stack[1])); assert(/DEBUG: This is deprecated/.test(stack[0])); diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index b4ae7054d7..190966083e 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -11,11 +11,11 @@ const net = require('net'); const COUNT = httpCommon.parsers.max + 1; const parsers = new Array(COUNT); -for (var i = 0; i < parsers.length; i++) +for (let i = 0; i < parsers.length; i++) parsers[i] = httpCommon.parsers.alloc(); -var gotRequests = 0; -var gotResponses = 0; +let gotRequests = 0; +let gotResponses = 0; function execAndClose() { if (parsers.length === 0) @@ -50,7 +50,7 @@ function execAndClose() { }; } -var server = net.createServer(function(c) { +const server = net.createServer(function(c) { if (++gotRequests === COUNT) server.close(); c.end('HTTP/1.1 200 OK\r\n\r\n', function() { diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 54fcc5c06a..dd4e7ba76b 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -101,7 +101,7 @@ assert.ok(my_path.path_func instanceof Function); // this one does not exist and should throw assert.throws(function() { require('./utils'); }); -var errorThrown = false; +let errorThrown = false; try { require('../fixtures/throws_error'); } catch (e) { @@ -113,7 +113,7 @@ assert.strictEqual(require('path').dirname(__filename), __dirname); console.error('load custom file types with extensions'); require.extensions['.test'] = function(module, filename) { - var content = fs.readFileSync(filename).toString(); + let content = fs.readFileSync(filename).toString(); assert.strictEqual('this is custom source\n', content); content = content.replace('this is custom source', 'exports.test = \'passed\''); @@ -193,8 +193,8 @@ assert.deepStrictEqual(json, { // modules that we've required, and that all of them contain // the appropriate children, and so on. -var children = module.children.reduce(function red(set, child) { - var id = path.relative(path.dirname(__dirname), child.id); +const children = module.children.reduce(function red(set, child) { + let id = path.relative(path.dirname(__dirname), child.id); id = id.replace(/\\/g, '/'); set[id] = child.children.reduce(red, {}); return set; diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index b40cfb400b..a7f64c2e73 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -19,7 +19,7 @@ switch (process.argv[2]) { function server() { const net = require('net'); - var content = Buffer.alloc(64 * 1024 * 1024, '#'); + const content = Buffer.alloc(64 * 1024 * 1024, '#'); net.createServer(function(socket) { this.close(); socket.on('end', function() { @@ -36,7 +36,7 @@ function server() { function client() { const net = require('net'); - var client = net.connect({ + const client = net.connect({ host: common.localhostIPv4, port: common.PORT }, function() { @@ -46,14 +46,14 @@ function client() { function parent() { const spawn = require('child_process').spawn; - var node = process.execPath; + const node = process.execPath; - var s = spawn(node, [__filename, 'server'], { + const s = spawn(node, [__filename, 'server'], { env: Object.assign(process.env, { NODE_DEBUG: 'net' }) }); - var c; + let c; wrap(s.stderr, process.stderr, 'SERVER 2>'); wrap(s.stdout, process.stdout, 'SERVER 1>'); diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-regress-GH-1697.js index 1511cfd1cf..d99acf9e46 100644 --- a/test/sequential/test-regress-GH-1697.js +++ b/test/sequential/test-regress-GH-1697.js @@ -6,7 +6,7 @@ const cp = require('child_process'); if (process.argv[2] === 'server') { // Server - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { conn.on('data', function(data) { console.log('server received ' + data.length + ' bytes'); }); @@ -23,22 +23,22 @@ if (process.argv[2] === 'server') { } else { // Client - var serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']); + const serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']); serverProcess.stdout.pipe(process.stdout); serverProcess.stderr.pipe(process.stdout); serverProcess.stdout.once('data', function() { - var client = net.createConnection(common.PORT, '127.0.0.1'); + const client = net.createConnection(common.PORT, '127.0.0.1'); client.on('connect', function() { const alot = Buffer.allocUnsafe(1024); const alittle = Buffer.allocUnsafe(1); - for (var i = 0; i < 100; i++) { + for (let i = 0; i < 100; i++) { client.write(alot); } // Block the event loop for 1 second - var start = (new Date()).getTime(); + const start = (new Date()).getTime(); while ((new Date()).getTime() < start + 1000) {} client.write(alittle); diff --git a/test/sequential/test-regress-GH-1726.js b/test/sequential/test-regress-GH-1726.js index 0097ed913d..c464193b23 100644 --- a/test/sequential/test-regress-GH-1726.js +++ b/test/sequential/test-regress-GH-1726.js @@ -8,8 +8,8 @@ require('../common'); const assert = require('assert'); const ch = require('child_process'); -var gen = +(process.argv[2] || 0); -var maxGen = 5; +const gen = +(process.argv[2] || 0); +const maxGen = 5; if (gen === maxGen) { @@ -17,7 +17,7 @@ if (gen === maxGen) { return; } -var child = ch.spawn(process.execPath, [__filename, gen + 1], { +const child = ch.spawn(process.execPath, [__filename, gen + 1], { stdio: [ 'ignore', 'pipe', 'ignore' ] }); assert.ok(!child.stdin); diff --git a/test/sequential/test-regress-GH-4015.js b/test/sequential/test-regress-GH-4015.js index 87b2b8561d..249817de1d 100644 --- a/test/sequential/test-regress-GH-4015.js +++ b/test/sequential/test-regress-GH-4015.js @@ -3,8 +3,8 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -var cmd = '"' + process.execPath + '" ' + - '"' + common.fixturesDir + '/test-regress-GH-4015.js"'; +const cmd = '"' + process.execPath + '" ' + + '"' + common.fixturesDir + '/test-regress-GH-4015.js"'; exec(cmd, function(err, stdout, stderr) { assert(/RangeError: Maximum call stack size exceeded/.test(stderr)); diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-regress-GH-4027.js index 7653dda182..87a8861ac3 100644 --- a/test/sequential/test-regress-GH-4027.js +++ b/test/sequential/test-regress-GH-4027.js @@ -6,7 +6,7 @@ const fs = require('fs'); common.refreshTmpDir(); -var filename = path.join(common.tmpDir, 'watched'); +const filename = path.join(common.tmpDir, 'watched'); fs.writeFileSync(filename, 'quis custodiet ipsos custodes'); setTimeout(fs.unlinkSync, 100, filename); diff --git a/test/sequential/test-regress-GH-784.js b/test/sequential/test-regress-GH-784.js index 645ffeb650..c9b630b0c8 100644 --- a/test/sequential/test-regress-GH-784.js +++ b/test/sequential/test-regress-GH-784.js @@ -12,8 +12,8 @@ const http = require('http'); const assert = require('assert'); -var server = http.createServer(function(req, res) { - var body = ''; +const server = http.createServer(function(req, res) { + let body = ''; req.setEncoding('utf8'); req.on('data', function(chunk) { @@ -43,7 +43,7 @@ function serverOff() { pingping(); } -var responses = []; +const responses = []; function afterPing(result) { @@ -81,14 +81,14 @@ function afterPing(result) { function ping() { console.error('making req'); - var opt = { + const opt = { port: common.PORT, path: '/ping', method: 'POST' }; - var req = http.request(opt, function(res) { - var body = ''; + const req = http.request(opt, function(res) { + let body = ''; res.setEncoding('utf8'); res.on('data', function(chunk) { @@ -105,8 +105,8 @@ function ping() { req.end('PING'); - var gotEnd = false; - var hadError = false; + let gotEnd = false; + let hadError = false; req.on('error', function(error) { console.log('Error making ping req: ' + error); diff --git a/test/sequential/test-regress-GH-877.js b/test/sequential/test-regress-GH-877.js index 82229524ce..06c839aa48 100644 --- a/test/sequential/test-regress-GH-877.js +++ b/test/sequential/test-regress-GH-877.js @@ -3,28 +3,28 @@ const common = require('../common'); const http = require('http'); const assert = require('assert'); -var N = 20; -var responses = 0; -var maxQueued = 0; +const N = 20; +let responses = 0; +let maxQueued = 0; -var agent = http.globalAgent; +const agent = http.globalAgent; agent.maxSockets = 10; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); res.end('Hello World\n'); }); -var addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); +const addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); server.listen(common.PORT, '127.0.0.1', function() { - for (var i = 0; i < N; i++) { - var options = { + for (let i = 0; i < N; i++) { + const options = { host: '127.0.0.1', port: common.PORT }; - var req = http.get(options, function(res) { + const req = http.get(options, function(res) { if (++responses === N) { server.close(); } @@ -37,7 +37,7 @@ server.listen(common.PORT, '127.0.0.1', function() { agent.maxSockets + ' queued: ' + (agent.requests[addrString] ? agent.requests[addrString].length : 0)); - var agentRequests = agent.requests[addrString] ? + const agentRequests = agent.requests[addrString] ? agent.requests[addrString].length : 0; if (maxQueued < agentRequests) { diff --git a/test/sequential/test-repl-timeout-throw.js b/test/sequential/test-repl-timeout-throw.js index 344845e020..6966419556 100644 --- a/test/sequential/test-repl-timeout-throw.js +++ b/test/sequential/test-repl-timeout-throw.js @@ -8,7 +8,7 @@ const child = spawn(process.execPath, [ '-i' ], { stdio: [null, null, 2] }); -var stdout = ''; +let stdout = ''; child.stdout.setEncoding('utf8'); child.stdout.on('data', function(c) { process.stdout.write(c); @@ -30,7 +30,7 @@ child.stdout.once('data', function() { setTimeout(fsTest, 50); function fsTest() { - var f = JSON.stringify(__filename); + const f = JSON.stringify(__filename); child.stdin.write('fs.readFile(' + f + ', thrower);\n'); setTimeout(eeTest, 50); } @@ -54,6 +54,6 @@ child.stdout.once('data', function() { child.on('close', function(c) { assert.strictEqual(c, 0); // make sure we got 3 throws, in the end. - var lastLine = stdout.trim().split(/\r?\n/).pop(); + const lastLine = stdout.trim().split(/\r?\n/).pop(); assert.strictEqual(lastLine, '> 3'); }); diff --git a/test/sequential/test-require-cache-without-stat.js b/test/sequential/test-require-cache-without-stat.js index 0549e5f72e..b591f1746b 100644 --- a/test/sequential/test-require-cache-without-stat.js +++ b/test/sequential/test-require-cache-without-stat.js @@ -6,13 +6,13 @@ const common = require('../common'); const fs = require('fs'); const assert = require('assert'); -var counter = 0; +let counter = 0; // Switch out the two stat implementations so that they increase a counter // each time they are called. -var _statSync = fs.statSync; -var _stat = fs.stat; +const _statSync = fs.statSync; +const _stat = fs.stat; fs.statSync = function() { counter++; @@ -31,7 +31,7 @@ require('./../fixtures/a.js'); require('http'); console.log('counterBefore = %d', counter); -var counterBefore = counter; +const counterBefore = counter; // Now load the module a bunch of times with equivalent paths. // stat should not be called. @@ -47,6 +47,6 @@ for (let i = 0; i < 100; i++) { } console.log('counterAfter = %d', counter); -var counterAfter = counter; +const counterAfter = counter; assert.equal(counterBefore, counterAfter); diff --git a/test/sequential/test-stream2-fs.js b/test/sequential/test-stream2-fs.js index 3640749179..2891335c81 100644 --- a/test/sequential/test-stream2-fs.js +++ b/test/sequential/test-stream2-fs.js @@ -3,14 +3,14 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); -var FSReadable = fs.ReadStream; +const FSReadable = fs.ReadStream; const path = require('path'); -var file = path.resolve(common.fixturesDir, 'x1024.txt'); +const file = path.resolve(common.fixturesDir, 'x1024.txt'); -var size = fs.statSync(file).size; +const size = fs.statSync(file).size; -var expectLengths = [1024]; +const expectLengths = [1024]; const util = require('util'); const Stream = require('stream'); @@ -34,8 +34,8 @@ TestWriter.prototype.end = function(c) { this.emit('results', this.buffer); }; -var r = new FSReadable(file); -var w = new TestWriter(); +const r = new FSReadable(file); +const w = new TestWriter(); w.on('results', function(res) { console.error(res, w.length); diff --git a/test/sequential/test-stream2-stderr-sync.js b/test/sequential/test-stream2-stderr-sync.js index 2855a5f097..e37a5f2cd1 100644 --- a/test/sequential/test-stream2-stderr-sync.js +++ b/test/sequential/test-stream2-stderr-sync.js @@ -6,10 +6,10 @@ require('../common'); function parent() { const spawn = require('child_process').spawn; const assert = require('assert'); - var i = 0; + let i = 0; children.forEach(function(_, c) { - var child = spawn(process.execPath, [__filename, '' + c]); - var err = ''; + const child = spawn(process.execPath, [__filename, '' + c]); + let err = ''; child.stderr.on('data', function(c) { err += c; @@ -43,7 +43,7 @@ function child1() { // using a net socket function child2() { const net = require('net'); - var socket = new net.Socket({ + const socket = new net.Socket({ fd: 2, readable: false, writable: true}); @@ -62,7 +62,7 @@ function child4() { process.stderr.write('child 4\nfoo\nbar\nbaz\n'); } -var children = [ child0, child1, child2, child3, child4 ]; +const children = [ child0, child1, child2, child3, child4 ]; if (!process.argv[2]) { parent(); diff --git a/test/sequential/test-timers-blocking-callback.js b/test/sequential/test-timers-blocking-callback.js index e4e85cddc6..73b0f13997 100644 --- a/test/sequential/test-timers-blocking-callback.js +++ b/test/sequential/test-timers-blocking-callback.js @@ -28,9 +28,9 @@ const Timer = process.binding('timer_wrap').Timer; const TIMEOUT = 100; -var nbBlockingCallbackCalls = 0; -var latestDelay = 0; -var timeCallbackScheduled = 0; +let nbBlockingCallbackCalls = 0; +let latestDelay = 0; +let timeCallbackScheduled = 0; function initTest() { nbBlockingCallbackCalls = 0; diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index d55a9b310c..a434e2ae3e 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -5,11 +5,11 @@ const vm = require('vm'); const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { - var code = 'var j = 0;\n' + - 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + - 'j;'; + const code = 'let j = 0;\n' + + 'for (let i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + + 'j;'; - var ctx = vm.createContext({ + const ctx = vm.createContext({ add: function(x, y) { return x + y; } @@ -17,8 +17,8 @@ if (process.argv[2] === 'child') { vm.runInContext(code, ctx, { timeout: 1 }); } else { - var proc = spawn(process.execPath, process.argv.slice(1).concat('child')); - var err = ''; + const proc = spawn(process.execPath, process.argv.slice(1).concat('child')); + let err = ''; proc.stderr.on('data', function(data) { err += data; }); |