[Pkg-javascript-commits] [node-stack-utils] 07/67: Fix tests for older versions of Node.

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:53:01 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 dd89c4be0d8326aab117398af3bf17c041f87890
Author: James Talmage <james at talmage.io>
Date:   Sun Jan 3 23:53:35 2016 -0500

    Fix tests for older versions of Node.
    
    Eval statements produce a slightly different stack trace that ends up getting parsed differently.
---
 test.js | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/test.js b/test.js
index 7090c52..51ce222 100644
--- a/test.js
+++ b/test.js
@@ -8,6 +8,10 @@ const LinuxStack1 = join(linuxStack1(), internalStack());
 const WindowsStack1 = join(windowsStack1(), internalStack());
 const fixtureDir = path.join(__dirname, 'fixtures');
 
+const version = process.version.slice(1).split('.').map(function (val) {
+	return parseInt(val, 10);
+});
+
 test('must be called with new', t => {
 	t.is(typeof StackUtils, 'function');
 	const stackUtils = StackUtils;
@@ -212,14 +216,20 @@ test('at: eval', t => {
 	const capture = new CaptureFixture(stackUtil);
 
 	const at = capture.eval('call', 'at', capture.call);
-
-	t.same(at, {
+	const expected = {
 		line: 1,
 		column: 14,
 		evalOrigin: 'eval at <anonymous> (' + path.join(fixtureDir, 'capture-fixture.js') + ':57:9)',
 		function: 'eval'
-	});
-	t.pass();
+	};
+
+	// TODO: There are some inconsistencies between this and how `parseLine` works.
+	if (version[0] < 4) {
+		expected.type = 'CaptureFixture';
+		expected.function = 'eval';
+	}
+
+	t.same(at, expected);
 });
 
 test('parseLine', t => {
@@ -251,9 +261,10 @@ test('parseLine', t => {
 		function: 'Foo'
 	});
 
+	// EVAL
 	const evalStack = capture.eval('error', 'foo').stack.split('\n');
 
-	t.same(stack.parseLine(evalStack[2]), {
+	const expected = {
 		file: '<anonymous>',
 		line: 1,
 		column: 14,
@@ -262,7 +273,15 @@ test('parseLine', t => {
 		evalColumn: 9,
 		evalFile: path.join(fixtureDir, 'capture-fixture.js'),
 		function: 'eval'
-	});
+	};
+
+	if (version[0] < 4) {
+		expected.function = 'CaptureFixture.eval';
+	}
+
+	const actual = stack.parseLine(evalStack[2]);
+
+	t.same(actual, expected);
 });
 
 function join() {

-- 
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