From 774b28fde7035b076f5d80ade2ea293b18f2084b Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 26 May 2013 12:26:39 -0400 Subject: [PATCH] repl: fix JSON.parse error check Before this, entering something like: > JSON.parse('066'); resulted in the "..." prompt instead of displaying the expected "SyntaxError: Unexpected number" --- lib/repl.js | 3 +-- test/simple/test-repl.js | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 84441ef130..c726065e3f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -923,6 +923,5 @@ function isSyntaxError(e) { // "strict mode" syntax errors !e.match(/^SyntaxError: .*strict mode.*/i) && // JSON.parse() error - !(e.match(/^SyntaxError: Unexpected (token .*|end of input)/) && - e.match(/\n {4}at Object.parse \(native\)\n/)); + !e.match(/\n {4}at Object.parse \(native\)\n/); } diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index 27c2058b01..2c04e2c1bd 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -134,6 +134,9 @@ function error_test() { expect: /^SyntaxError: 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/ }, + // should throw { client: client_unix, send: 'JSON.parse(\'{\');', expect: /^SyntaxError: Unexpected end of input/ }, // invalid RegExps are a special case of syntax error,