不要怂,就是干,撸起袖子干!

You need to sign in or sign up before continuing.
Commit 93814d5a by Mick Hansen

Merge pull request #3741 from briandamaged/master

Call stacks are computed properly
2 parents 926bab6e 1a82d8ed
Showing with 29 additions and 2 deletions
......@@ -294,11 +294,11 @@ var Utils = module.exports = {
},
stack: function() {
stack: function _stackGrabber() {
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack) { return stack; };
var err = new Error();
Error.captureStackTrace(err, this);
Error.captureStackTrace(err, _stackGrabber);
var errStack = err.stack;
Error.prepareStackTrace = orig;
return errStack;
......
......@@ -114,4 +114,30 @@ suite(Support.getTestDialectTeaser('Utils'), function() {
});
});
});
suite('stack', function() {
test('stack trace starts after call to Util.stack()', function this_here_test() {
function a() {
return b();
}
function b() {
return c();
}
function c() {
return Utils.stack();
}
var stack = a();
expect(stack[0].getFunctionName()).to.eql('c');
expect(stack[1].getFunctionName()).to.eql('b');
expect(stack[2].getFunctionName()).to.eql('a');
expect(stack[3].getFunctionName()).to.eql('this_here_test');
});
});
});
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!