Skip to content

Commit

Permalink
add test for parseLine that can not resolve the filename or line/co…
Browse files Browse the repository at this point in the history
…lumn numbers
  • Loading branch information
jamestalmage committed Jan 7, 2016
1 parent 6579935 commit 85faa3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,15 @@ StackUtils.prototype.parseLine = function parseLine(line) {
var col = match[10];
var native = match[11] === 'native';

var res = {
line: Number(lnum),
column: Number(col)
};
var res = {};

if (lnum) {
res.line = Number(lnum);
}

if (col) {
res.column = Number(col);
}

if (file) {
file = file.replace(/\\/g, '/');
Expand Down
11 changes: 9 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test('at: with stackStart', t => {
const at = capture.redirect1('call', 'at', capture.call);

t.same(at, {
file: `fixtures${path.sep}capture-fixture.js`,
file: `fixtures/capture-fixture.js`,
line: 11,
column: 22,
type: 'CaptureFixture',
Expand Down Expand Up @@ -274,7 +274,7 @@ test('parseLine', t => {
evalOrigin: '<anonymous>',
evalLine: 57,
evalColumn: 9,
evalFile: path.join(fixtureDir, 'capture-fixture.js'),
evalFile: path.join(fixtureDir, 'capture-fixture.js').replace(/\\/g, '/'),
function: 'eval'
};

Expand All @@ -287,6 +287,13 @@ test('parseLine', t => {
t.same(actual, expected);
});

test('parseLine: handles native errors', t => {
t.same(StackUtils.parseLine(' at Error (native)'), {
native: true,
function: 'Error'
});
});

function join() {
var args = Array.prototype.slice.call(arguments);
return flatten(args).join('\n') + '\n';
Expand Down

0 comments on commit 85faa3a

Please sign in to comment.