Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
debugger: remove useless clearlines, updated test
Browse files Browse the repository at this point in the history
* remove useless clearline call at Interface start
* silence after .handleBreak()
* output '\b' if this.stdout is not a tty (debugger)
* add '\b' checks for clearline (test)
  • Loading branch information
indutny authored and ry committed Sep 23, 2011
1 parent e406613 commit 39fec60
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
5 changes: 3 additions & 2 deletions lib/_debugger.js
Expand Up @@ -785,7 +785,6 @@ function Interface(stdin, stdout, args) {
this.breakpoints = [];

// Run script automatically
this.clearline();
this.pause();

// XXX Need to figure out why we need this delay
Expand Down Expand Up @@ -827,6 +826,8 @@ Interface.prototype.clearline = function() {
if (this.stdout.isTTY) {
this.stdout.cursorTo(0);
this.stdout.clearLine(1);
} else {
this.stdout.write('\b');
}
};

Expand Down Expand Up @@ -876,7 +877,7 @@ Interface.prototype.handleBreak = function(r) {
// And list source
this.list(2);

this.resume();
this.resume(true);
};


Expand Down
63 changes: 32 additions & 31 deletions test/simple/test-debugger-repl.js
Expand Up @@ -45,8 +45,6 @@ var expected = [];
child.on('line', function(line) {
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);

console.log(JSON.stringify(line) + ',');

var expectedLine = expected[0].lines.shift();
assert.equal(line, expectedLine);

Expand All @@ -72,45 +70,44 @@ function addTest(input, output) {

// Initial lines
addTest(null, [
"debug> < debugger listening on port 5858",
"debug> connecting... ok",
"debug> break in [unnamed]:3",
" 1 ",
" 2 debugger;",
" 3 debugger;",
" 4 function a(x) {",
" 5 var i = 10;"
"debug> \b< debugger listening on port 5858",
"debug> \bconnecting... ok",
"debug> \bbreak in [unnamed]:3",
"\b 1 ",
"\b 2 debugger;",
"\b 3 debugger;",
"\b 4 function a(x) {",
"\b 5 var i = 10;"
]);

// Next
addTest('n', [
"debug> debug> debug> break in [unnamed]:13",
" 11 return [\"hello\", \"world\"].join(\" \");",
" 12 };",
" 13 a();",
" 14 a(1);",
" 15 b();"
"debug> debug> debug> \bbreak in [unnamed]:13",
"\b 11 return ['hello', 'world'].join(' ');",
"\b 12 };",
"\b 13 a();",
"\b 14 a(1);",
"\b 15 b();"
]);

// Continue
addTest('c', [
"debug> debug> debug> break in [unnamed]:7",
" 5 var i = 10;",
" 6 while (--i != 0);",
" 7 debugger;",
" 8 return i;",
" 9 };"
"debug> debug> debug> \bbreak in [unnamed]:7",
"\b 5 var i = 10;",
"\b 6 while (--i != 0);",
"\b 7 debugger;",
"\b 8 return i;",
"\b 9 };"
]);


// Step out
addTest('o', [
"debug> debug> debug> break in [unnamed]:14",
" 12 };",
" 13 a();",
" 14 a(1);",
" 15 b();",
" 16 b();"
"debug> debug> debug> \bbreak in [unnamed]:14",
"\b 12 };",
"\b 13 a();",
"\b 14 a(1);",
"\b 15 b();",
"\b 16 b();"
]);


Expand All @@ -130,9 +127,13 @@ setTimeout(function() {

process.once('uncaughtException', function(e) {
quit();
throw e;
console.error(e.toString());
process.exit(1);
});

process.on('exit', function() {
process.on('exit', function(code) {
quit();
if (code === 0) {
assert.equal(expected.length, 0);
}
});

0 comments on commit 39fec60

Please sign in to comment.