Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add initial code

  • Loading branch information...
commit 3a1e114788fe8f488bd45556c63fed8ceb254fb4 1 parent 3de0ddd
@felixge authored
View
14 lib/stack-trace.js
@@ -0,0 +1,14 @@
+exports.get = function(belowFn) {
+ var dummyObject = {};
+ Error.captureStackTrace(dummyObject, belowFn || exports.get);
+
+ var v8Handler = Error.prepareStackTrace;
+ Error.prepareStackTrace = function(dummyObject, v8StackTrace) {
+ return v8StackTrace;
+ };
+
+ var v8StackTrace = dummyObject.stack;
+ Error.prepareStackTrace = v8Handler;
+
+ return v8StackTrace;
+};
View
10 test/common.js
@@ -0,0 +1,10 @@
+var common = exports;
+
+var path = require('path');
+var root = path.dirname(__dirname);
+
+common.dir = {
+ lib: root + '/lib',
+};
+
+common.assert = require('assert');
View
17 test/integration/test-basic.js
@@ -0,0 +1,17 @@
+var common = require('../common');
+var assert = common.assert;
+var stackTrace = require(common.dir.lib + '/stack-trace');
+
+(function testBasic() {
+ var trace = stackTrace.get();
+
+ assert.strictEqual(trace[0].getFunction(), testBasic);
+ assert.strictEqual(trace[0].getFileName(), __filename);
+})();
+
+(function testWrapper() {
+ (function testBelowFn() {
+ var trace = stackTrace.get(testBelowFn);
+ assert.strictEqual(trace[0].getFunction(), testWrapper);
+ })();
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.