Skip to content

Commit

Permalink
repl: Add test for recoverable errors
Browse files Browse the repository at this point in the history
  • Loading branch information
islandryu committed Sep 9, 2024
1 parent 7dfc689 commit c3f8b21
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ const possibleTokensAfterIdentifier = [
'? 1: 1',
];

const possibleTokensAfterIdentifierWithLineBreak = [
'(\n)',
'[\n0]',
'+\n1', '- \n1', '* \n1', '/ \n1', '% \n1', '** \n1',
'== \n1', '=== \n1', '!= \n1', '!== \n1', '< \n1', '> \n1', '<= \n1', '>= \n1',
'&& \n1', '|| \n1', '?? \n1',
'= \n1', '+= \n1', '-= \n1', '*= \n1', '/= \n1', '%= \n1',
': \n',
'? \n1: 1',
]

const errorTests = [
// Uncaught error throws and prints out
{
Expand Down Expand Up @@ -408,6 +419,16 @@ const errorTests = [
expect: 'undefined'
}
)),
{
send: 'npm = () => {};',
expect: '[Function: npm]'
},
...possibleTokensAfterIdentifierWithLineBreak.map((token) => (
{
send: `npm ${token}; undefined`,
expect: '... undefined'
}
)),
{
send: '(function() {\n\nreturn 1;\n})()',
expect: '... ... ... 1'
Expand Down

0 comments on commit c3f8b21

Please sign in to comment.