[Pkg-javascript-commits] [node-stack-utils] 21/67: add test for `parseLine` that can not resolve the filename or line/column numbers

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:53:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-stack-utils.

commit 85faa3aaf214679fca5c273cacc70b2ced0b6c97
Author: James Talmage <james at talmage.io>
Date:   Thu Jan 7 15:49:45 2016 -0500

    add test for `parseLine` that can not resolve the filename or line/column numbers
---
 index.js | 13 +++++++++----
 test.js  | 11 +++++++++--
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/index.js b/index.js
index 8d2301e..c1e8ce1 100644
--- a/index.js
+++ b/index.js
@@ -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, '/');
diff --git a/test.js b/test.js
index 7afc564..555b095 100644
--- a/test.js
+++ b/test.js
@@ -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',
@@ -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'
 	};
 
@@ -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';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stack-utils.git



More information about the Pkg-javascript-commits mailing list