Skip to content

Commit

Permalink
test: adapt test-repl-pretty-*stack to V8 changes
Browse files Browse the repository at this point in the history
PR-URL: #44741
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
targos committed Oct 11, 2022
1 parent 71c193e commit 96ef257
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
18 changes: 12 additions & 6 deletions test/parallel/test-repl-pretty-custom-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ function run({ command, expected }) {
});

r.write(`${command}\n`);
assert.strictEqual(
accum.replace(stackRegExp, '$1:*:*'),
expected.replace(stackRegExp, '$1:*:*')
);
if (typeof expected === 'string') {
assert.strictEqual(
accum.replace(stackRegExp, '$1:*:*'),
expected.replace(stackRegExp, '$1:*:*')
);
} else {
assert.match(
accum.replace(stackRegExp, '$1:*:*'),
expected
);
}
r.close();
}

Expand All @@ -53,8 +60,7 @@ const tests = [
},
{
command: 'let x y;',
expected: 'let x y;\n ^\n\n' +
'Uncaught SyntaxError: Unexpected identifier\n'
expected: /let x y;\n {6}\^\n\nUncaught SyntaxError: Unexpected identifier.*\n/
},
{
command: 'throw new Error(\'Whoops!\')',
Expand Down
18 changes: 12 additions & 6 deletions test/parallel/test-repl-pretty-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ function run({ command, expected, ...extraREPLOptions }, i) {

r.write(`${command}\n`);
console.log(i);
assert.strictEqual(
accum.replace(stackRegExp, '$1*:*'),
expected.replace(stackRegExp, '$1*:*')
);
if (typeof expected === 'string') {
assert.strictEqual(
accum.replace(stackRegExp, '$1*:*'),
expected.replace(stackRegExp, '$1*:*')
);
} else {
assert.match(
accum.replace(stackRegExp, '$1*:*'),
expected
);
}
r.close();
}

Expand All @@ -43,8 +50,7 @@ const tests = [
},
{
command: 'let x y;',
expected: 'let x y;\n ^\n\n' +
'Uncaught SyntaxError: Unexpected identifier\n'
expected: /^let x y;\n {6}\^\n\nUncaught SyntaxError: Unexpected identifier.*\n/
},
{
command: 'throw new Error(\'Whoops!\')',
Expand Down

0 comments on commit 96ef257

Please sign in to comment.