Skip to content

Commit

Permalink
test: make error stack test engine agnostic
Browse files Browse the repository at this point in the history
Revise test-internal-util-decorate-error-stack so that it does not
depend on behavior specific to V8.

PR-URL: #16272
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
Trott authored and evanlucas committed Nov 13, 2017
1 parent b5b23bd commit 79e1831
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/parallel/test-internal-util-decorate-error-stack.js
Expand Up @@ -24,11 +24,16 @@ const obj = {};
decorateErrorStack(obj);
assert.strictEqual(obj.stack, undefined);

// Verify that the stack is decorated when possible
// Verify that the stack is decorated when possible.
function checkStack(stack) {
const matches = stack.match(/var foo bar;/g);
assert.strictEqual(Array.isArray(matches), true);
assert.strictEqual(matches.length, 1);
// Matching only on a minimal piece of the stack because the string will vary
// greatly depending on the JavaScript engine. V8 includes `;` because it
// displays the line of code (`var foo bar;`) that is causing a problem.
// ChakraCore does not display the line of code but includes `;` in the phrase
// `Expected ';' `.
assert.ok(/;/g.test(stack));
// Test that it's a multiline string.
assert.ok(/\n/g.test(stack));
}
let err;
const badSyntaxPath =
Expand Down

0 comments on commit 79e1831

Please sign in to comment.