test-debugger-repl improvements

v0.7.4-release
Fedor Indutny 2011-09-23 22:28:32 +07:00 committed by Ryan Dahl
parent 78d91ff074
commit e406613ee5
2 changed files with 28 additions and 29 deletions

16
test/fixtures/breakpoints.js vendored 100644
View File

@ -0,0 +1,16 @@
// wrapper line
debugger;
debugger;
function a(x) {
var i = 10;
while (--i != 0);
debugger;
return i;
};
function b() {
return ['hello', 'world'].join(' ');
};
a();
a(1);
b();
b();

View File

@ -25,28 +25,12 @@ var assert = require('assert');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var debug = require('_debugger'); var debug = require('_debugger');
var code = [ var code = require('fs').readFileSync(common.fixturesDir + '/breakpoints.js');
'',
'debugger;',
'debugger;',
'function a(x) {',
' var i = 10;',
' while (--i != 0);',
' debugger;',
' return i;',
'}',
'function b() {',
' return ["hello", "world"].join(" ");',
'}',
'a()',
'a(1)',
'b()',
'b()'
].join('\n');
var child = spawn(process.execPath, ['debug', '-e', code]); var child = spawn(process.execPath, ['debug', '-e', code]);
var buffer = ''; var buffer = '';
child.stdout.setEncoding('utf-8');
child.stdout.on('data', function(data) { child.stdout.on('data', function(data) {
data = (buffer + data.toString()).split(/\n/g); data = (buffer + data.toString()).split(/\n/g);
buffer = data.pop(); buffer = data.pop();
@ -102,10 +86,10 @@ addTest(null, [
addTest('n', [ addTest('n', [
"debug> debug> debug> break in [unnamed]:13", "debug> debug> debug> break in [unnamed]:13",
" 11 return [\"hello\", \"world\"].join(\" \");", " 11 return [\"hello\", \"world\"].join(\" \");",
" 12 }", " 12 };",
" 13 a()", " 13 a();",
" 14 a(1)", " 14 a(1);",
" 15 b()" " 15 b();"
]); ]);
// Continue // Continue
@ -115,23 +99,22 @@ addTest('c', [
" 6 while (--i != 0);", " 6 while (--i != 0);",
" 7 debugger;", " 7 debugger;",
" 8 return i;", " 8 return i;",
" 9 }" " 9 };"
]); ]);
// Step out // Step out
addTest('o', [ addTest('o', [
"debug> debug> debug> break in [unnamed]:14", "debug> debug> debug> break in [unnamed]:14",
" 12 }", " 12 };",
" 13 a()", " 13 a();",
" 14 a(1)", " 14 a(1);",
" 15 b()", " 15 b();",
" 16 b()" " 16 b();"
]); ]);
function finish() { function finish() {
console.log('passed');
process.exit(0); process.exit(0);
}; };