repl: fix JSON.parse error check
authorBrian White <mscdex@mscdex.net>
Sun, 26 May 2013 16:26:39 +0000 (12:26 -0400)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 30 May 2013 12:41:00 +0000 (14:41 +0200)
Before this, entering something like:

> JSON.parse('066');

resulted in the "..." prompt instead of displaying the expected
"SyntaxError: Unexpected number"

lib/repl.js
test/simple/test-repl.js

index 84441ef130c65876d80950c2c117d277002939de..c726065e3f6e771632a570c76fc8cd89fea74a6f 100644 (file)
@@ -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/);
 }
index 27c2058b013fe875b3dd15a6a11cb075708a4d90..2c04e2c1bdf705e573103c57df565288571a3eeb 100644 (file)
@@ -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,