Skip to content

Commit

Permalink
test: use ES6 in test-debugger-client.js
Browse files Browse the repository at this point in the history
implements ES6 const and let instead var in test-debugger-client.js

PR-URL: #10183
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Italo A. Casas <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
edsadr authored and Fishrock123 committed Dec 13, 2016
1 parent 80cccce commit 3f269cc
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions test/debugger/test-debugger-client.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var debug = require('_debugger');
const assert = require('assert');
const debug = require('_debugger');

process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var debugPort = common.PORT;
const debugPort = common.PORT;
debug.port = debugPort;
var spawn = require('child_process').spawn;
const spawn = require('child_process').spawn;

setTimeout(function() {
if (nodeProcess) nodeProcess.kill('SIGTERM');
throw new Error('timeout');
}, 10000).unref();


var resCount = 0;
var p = new debug.Protocol();
let resCount = 0;
const p = new debug.Protocol();
p.onResponse = function(res) {
resCount++;
};
Expand All @@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);

// Make sure split messages go in.

var parts = [];
const parts = [];
parts.push('Content-Length: 336\r\n');
assert.strictEqual(parts[0].length, 21);
parts.push('\r\n');
assert.strictEqual(parts[1].length, 2);
var bodyLength = 0;
let bodyLength = 0;

parts.push('{"seq":12,"type":"event","event":"break","body":' +
'{"invocationText":"#<a Server>');
Expand All @@ -55,32 +55,32 @@ bodyLength += parts[4].length;

assert.strictEqual(bodyLength, 336);

for (var i = 0; i < parts.length; i++) {
for (let i = 0; i < parts.length; i++) {
p.execute(parts[i]);
}
assert.strictEqual(resCount, 2);


// Make sure that if we get backed up, we still manage to get all the
// messages
var d = 'Content-Length: 466\r\n\r\n' +
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
'"sourceStart":"(function(module, exports, require) {' +
'var dns = process.binding(\'cares\')' +
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
'[{"handle":0' +
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
'\r\n\r\nContent-Length: 119\r\n\r\n' +
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
'"body":{"script":{"id":26}},"refs":[],"running":true}';
const d = 'Content-Length: 466\r\n\r\n' +
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
'"sourceStart":"(function(module, exports, require) {' +
'var dns = process.binding(\'cares\')' +
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType"' +
':0,"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
'[{"handle":0' +
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
'\r\n\r\nContent-Length: 119\r\n\r\n' +
'{"seq":11,"type":"event","event":"scriptCollected","success":true' +
',"body":{"script":{"id":26}},"refs":[],"running":true}';
p.execute(d);
assert.strictEqual(resCount, 4);

var expectedConnections = 0;
var tests = [];
let expectedConnections = 0;
const tests = [];
function addTest(cb) {
expectedConnections++;
tests.push(cb);
Expand All @@ -102,9 +102,9 @@ addTest(function(client, done) {
assert.ok(!err);
console.error('got %d scripts', Object.keys(client.scripts).length);

var foundMainScript = false;
for (var k in client.scripts) {
var script = client.scripts[k];
let foundMainScript = false;
for (const k in client.scripts) {
const script = client.scripts[k];
if (script && script.name === 'node.js') {
foundMainScript = true;
break;
Expand All @@ -127,19 +127,19 @@ addTest(function(client, done) {
});


var connectCount = 0;
var script = 'setTimeout(function() { console.log("blah"); });' +
'setInterval(function() {}, 1000000);';
let connectCount = 0;
const script = 'setTimeout(function() { console.log("blah"); });' +
'setInterval(function() {}, 1000000);';

var nodeProcess;
let nodeProcess;

function doTest(cb, done) {
var args = ['--debug=' + debugPort, '-e', script];
const args = ['--debug=' + debugPort, '-e', script];
nodeProcess = spawn(process.execPath, args);

nodeProcess.stdout.once('data', function(c) {
console.log('>>> new node process: %d', nodeProcess.pid);
var failed = true;
let failed = true;
try {
process._debugProcess(nodeProcess.pid);
failed = false;
Expand All @@ -151,9 +151,9 @@ function doTest(cb, done) {
console.log('>>> starting debugger session');
});

var didTryConnect = false;
let didTryConnect = false;
nodeProcess.stderr.setEncoding('utf8');
var b = '';
let b = '';
nodeProcess.stderr.on('data', function(data) {
console.error('got stderr data %j', data);
nodeProcess.stderr.resume();
Expand Down

0 comments on commit 3f269cc

Please sign in to comment.