Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add stepout command

  • Loading branch information...
commit 8c4aa00427b393ef849420b9a799bfa79de12399 1 parent 7042ce1
@smtlaissezfaire smtlaissezfaire authored
View
1  lib/ndb/commands.js
@@ -11,5 +11,6 @@ exports.Version = require("./commands/version");
exports.Verbose = require("./commands/verbose");
exports.Backtrace = require("./commands/backtrace");
exports.StepIn = require("./commands/step_in");
+exports.StepOut = require("./commands/step_out");
exports.History = require("./commands/history");
exports.REPL = require("./commands/repl");
View
28 lib/ndb/commands/step_out.js
@@ -0,0 +1,28 @@
+var ndb = require("ndb");
+
+exports.ndb = ndb;
+
+exports.commandNames = ["so", "stepout"];
+
+exports.parseCommand = function(text) {
+ var ndb = this.ndb;
+ return ndb.Helpers.commonParse.call(this, text);
+};
+
+exports.run = function(stepcount) {
+ var ndb = this.ndb,
+ rw = ndb.Commands.RawWrite;
+
+ if (stepcount === undefined) {
+ stepcount = 1;
+ }
+
+ rw.run({
+ type: "request",
+ command: "continue",
+ arguments: {
+ stepaction: "out",
+ stepcount: stepcount
+ }
+ });
+};
View
1  spec/node.js
@@ -32,6 +32,7 @@ JSpec.
exec('spec/unit/commands/list.js').
exec('spec/unit/commands/continue.js').
exec('spec/unit/commands/step_in.js').
+ exec('spec/unit/commands/step_out.js').
exec('spec/unit/commands/setbreakpoint.js').
exec('spec/unit/commands/quit.js').
exec('spec/unit/commands/version.js').
View
10 spec/unit/command_center.js
@@ -114,6 +114,16 @@ describe("NodeDebugger", function() {
parse[0].should.equal(ndb.Commands.StepIn);
});
+ it("should parse 'so' as a step out command", function() {
+ var parse = command_center.parse("so");
+ parse[0].should.equal(ndb.Commands.StepOut);
+ });
+
+ it("should parse 'stepout' as a step out command", function() {
+ var parse = command_center.parse("stepout");
+ parse[0].should.equal(ndb.Commands.StepOut);
+ });
+
it("should parse 'repl'", function() {
var parse = command_center.parse("repl");
parse[0].should.equal(ndb.Commands.REPL);
View
72 spec/unit/commands/step_out.js
@@ -0,0 +1,72 @@
+describe("NodeDebugger", function() {
+ describe("Commands", function() {
+ describe("step out", function() {
+ describe("running", function() {
+ before_each(function() {
+ connection = {
+ write: function() {}
+ };
+
+ commands = ndb.Commands;
+ commands.connection = connection;
+
+ c = commands.StepOut;
+ });
+
+ // {"seq":117,"type":"request","command":"continue"}
+ // {"seq":118,"type":"request","command":"continue","arguments":{"stepaction":"out"}}
+ // {"seq":119,"type":"request","command":"continue","arguments":{"stepaction":"next","stepcount":5}}
+
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "continue",
+ // "arguments" : { "stepaction" : <"in", "next" or "out">,
+ // "stepcount" : <number of steps (default 1)>
+ // }
+ // }
+ it("should raw_write the continue command", function() {
+ var obj = undefined;
+
+ spy.stub(ndb.Commands.RawWrite, "run", function(o) {
+ obj = o;
+ });
+
+ var expected_object = {
+ type: "request",
+ command: "continue",
+ arguments: {
+ stepaction: "out",
+ stepcount: 1
+ }
+ };
+
+ c.run();
+
+ JSON.stringify(obj).should.equal(JSON.stringify(expected_object));
+ });
+
+ it("should use the stepcount given when one is given", function() {
+ var obj = undefined;
+
+ spy.stub(ndb.Commands.RawWrite, "run", function(o) {
+ obj = o;
+ });
+
+ var expected_object = {
+ type: "request",
+ command: "continue",
+ arguments: {
+ stepaction: "out",
+ stepcount: 5
+ }
+ };
+
+ c.run(5);
+
+ JSON.stringify(obj).should.equal(JSON.stringify(expected_object));
+ true.should.equal(true);
+ });
+ });
+ });
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.