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 <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • 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
Original file line number Diff line number Diff line change
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.