mirror of https://github.com/nodejs/node.git
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"pull/41362/head
parent
9ee86b718c
commit
774b28fde7
|
@ -923,6 +923,5 @@ function isSyntaxError(e) {
|
||||||
// "strict mode" syntax errors
|
// "strict mode" syntax errors
|
||||||
!e.match(/^SyntaxError: .*strict mode.*/i) &&
|
!e.match(/^SyntaxError: .*strict mode.*/i) &&
|
||||||
// JSON.parse() error
|
// 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/));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,9 @@ function error_test() {
|
||||||
expect: /^SyntaxError: Unexpected token i/ },
|
expect: /^SyntaxError: Unexpected token i/ },
|
||||||
// end of input to JSON.parse error is special case of syntax error,
|
// end of input to JSON.parse error is special case of syntax error,
|
||||||
// should throw
|
// should throw
|
||||||
|
{ client: client_unix, send: 'JSON.parse(\'066\');',
|
||||||
|
expect: /^SyntaxError: Unexpected number/ },
|
||||||
|
// should throw
|
||||||
{ client: client_unix, send: 'JSON.parse(\'{\');',
|
{ client: client_unix, send: 'JSON.parse(\'{\');',
|
||||||
expect: /^SyntaxError: Unexpected end of input/ },
|
expect: /^SyntaxError: Unexpected end of input/ },
|
||||||
// invalid RegExps are a special case of syntax error,
|
// invalid RegExps are a special case of syntax error,
|
||||||
|
|
Loading…
Reference in New Issue