diff options
author | Prince J Wesley <princejohnwesley@gmail.com> | 2016-07-07 23:19:22 +0530 |
---|---|---|
committer | Prince J Wesley <princejohnwesley@gmail.com> | 2016-07-27 21:26:06 +0530 |
commit | 68ac0d0d7d82f8fde114ef4644c59ae6060e0b01 (patch) | |
tree | ca369d157ee4c4de7cccdc511557c2dd2ae76928 /test/parallel/test-repl.js | |
parent | 2554549ab5410745c4312a3b039e31e1620e05ab (diff) | |
download | android-node-v8-68ac0d0d7d82f8fde114ef4644c59ae6060e0b01.tar.gz android-node-v8-68ac0d0d7d82f8fde114ef4644c59ae6060e0b01.tar.bz2 android-node-v8-68ac0d0d7d82f8fde114ef4644c59ae6060e0b01.zip |
repl: Use displayErrors for SyntaxError
```js
node 🙈 ₹ git:(upstream ⚡ display-error-repl) ./node
> var 4;
var 4;
^
SyntaxError: Unexpected number
>
```
PR-URL: https://github.com/nodejs/node/pull/7589
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'test/parallel/test-repl.js')
-rw-r--r-- | test/parallel/test-repl.js | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 7936967202..495125f6dc 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -120,7 +120,7 @@ function error_test() { expect: prompt_unix }, // But passing the same string to eval() should throw { client: client_unix, send: 'eval("function test_func() {")', - expect: /^SyntaxError: Unexpected end of input/ }, + expect: /\bSyntaxError: Unexpected end of input/ }, // Can handle multiline template literals { client: client_unix, send: '`io.js', expect: prompt_multiline }, @@ -149,35 +149,35 @@ function error_test() { // invalid input to JSON.parse error is special case of syntax error, // should throw { client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');', - expect: /^SyntaxError: Unexpected token i/ }, + expect: /\bSyntaxError: Unexpected token i/ }, // end of input to JSON.parse error is special case of syntax error, // should throw { client: client_unix, send: 'JSON.parse(\'066\');', - expect: /^SyntaxError: Unexpected number/ }, + expect: /\bSyntaxError: Unexpected number/ }, // should throw { client: client_unix, send: 'JSON.parse(\'{\');', - expect: /^SyntaxError: Unexpected end of JSON input/ }, + expect: /\bSyntaxError: Unexpected end of JSON input/ }, // invalid RegExps are a special case of syntax error, // should throw { client: client_unix, send: '/(/;', - expect: /^SyntaxError: Invalid regular expression\:/ }, + expect: /\bSyntaxError: Invalid regular expression\:/ }, // invalid RegExp modifiers are a special case of syntax error, // should throw (GH-4012) { client: client_unix, send: 'new RegExp("foo", "wrong modifier");', - expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ }, + expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ }, // strict mode syntax errors should be caught (GH-5178) { client: client_unix, send: '(function() { "use strict"; return 0755; })()', - expect: /^SyntaxError: Octal literals are not allowed in strict mode/ }, + expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ }, { client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()', - expect: /^SyntaxError: Duplicate parameter name not allowed in this context/ }, + expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ }, { client: client_unix, send: '(function() { "use strict"; with (this) {} })()', - expect: /^SyntaxError: Strict mode code may not include a with statement/ }, + expect: /\bSyntaxError: Strict mode code may not include a with statement/ }, { client: client_unix, send: '(function() { "use strict"; var x; delete x; })()', - expect: /^SyntaxError: Delete of an unqualified identifier in strict mode/ }, + expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ }, { client: client_unix, send: '(function() { "use strict"; eval = 17; })()', - expect: /^SyntaxError: Unexpected eval or arguments in strict mode/ }, + expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ }, { client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()', - expect: /^SyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ }, + expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ }, // Named functions can be used: { client: client_unix, send: 'function blah() { return 1; }', expect: prompt_unix }, @@ -228,7 +228,7 @@ function error_test() { expect: 'Invalid REPL keyword\n' + prompt_unix }, // fail when we are not inside a String and a line continuation is used { client: client_unix, send: '[] \\', - expect: /^SyntaxError: Invalid or unexpected token/ }, + expect: /\bSyntaxError: Invalid or unexpected token/ }, // do not fail when a String is created with line continuation { client: client_unix, send: '\'the\\\nfourth\\\neye\'', expect: prompt_multiline + prompt_multiline + @@ -327,12 +327,18 @@ function error_test() { // Illegal token is not recoverable outside string literal, RegExp literal, // or block comment. https://github.com/nodejs/node/issues/3611 { client: client_unix, send: 'a = 3.5e', - expect: /^SyntaxError: Invalid or unexpected token/ }, + expect: /\bSyntaxError: Invalid or unexpected token/ }, // Mitigate https://github.com/nodejs/node/issues/548 { client: client_unix, send: 'function name(){ return "node"; };name()', expect: "'node'\n" + prompt_unix }, { client: client_unix, send: 'function name(){ return "nodejs"; };name()', expect: "'nodejs'\n" + prompt_unix }, + // Avoid emitting repl:line-number for SyntaxError + { client: client_unix, send: 'a = 3.5e', + expect: /^(?!repl)/ }, + // Avoid emitting stack trace + { client: client_unix, send: 'a = 3.5e', + expect: /^(?!\s+at\s)/gm }, ]); } |