From e406613ee552bf87837dc7cbbfdba8a6b7caf2c6 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 23 Sep 2011 22:28:32 +0700 Subject: [PATCH] test-debugger-repl improvements --- test/fixtures/breakpoints.js | 16 ++++++++++++ test/simple/test-debugger-repl.js | 41 +++++++++---------------------- 2 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 test/fixtures/breakpoints.js diff --git a/test/fixtures/breakpoints.js b/test/fixtures/breakpoints.js new file mode 100644 index 00000000000..ec6c526aa42 --- /dev/null +++ b/test/fixtures/breakpoints.js @@ -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(); diff --git a/test/simple/test-debugger-repl.js b/test/simple/test-debugger-repl.js index 1897f281751..9d9699308b9 100644 --- a/test/simple/test-debugger-repl.js +++ b/test/simple/test-debugger-repl.js @@ -25,28 +25,12 @@ var assert = require('assert'); var spawn = require('child_process').spawn; var debug = require('_debugger'); -var code = [ - '', - '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 code = require('fs').readFileSync(common.fixturesDir + '/breakpoints.js'); var child = spawn(process.execPath, ['debug', '-e', code]); var buffer = ''; +child.stdout.setEncoding('utf-8'); child.stdout.on('data', function(data) { data = (buffer + data.toString()).split(/\n/g); buffer = data.pop(); @@ -102,10 +86,10 @@ addTest(null, [ addTest('n', [ "debug> debug> debug> break in [unnamed]:13", " 11 return [\"hello\", \"world\"].join(\" \");", - " 12 }", - " 13 a()", - " 14 a(1)", - " 15 b()" + " 12 };", + " 13 a();", + " 14 a(1);", + " 15 b();" ]); // Continue @@ -115,23 +99,22 @@ addTest('c', [ " 6 while (--i != 0);", " 7 debugger;", " 8 return i;", - " 9 }" + " 9 };" ]); // Step out addTest('o', [ "debug> debug> debug> break in [unnamed]:14", - " 12 }", - " 13 a()", - " 14 a(1)", - " 15 b()", - " 16 b()" + " 12 };", + " 13 a();", + " 14 a(1);", + " 15 b();", + " 16 b();" ]); function finish() { - console.log('passed'); process.exit(0); };