repl: Use displayErrors for SyntaxError · nodejs/node@68ac0d0

@@ -120,7 +120,7 @@ function error_test() {

120120

expect: prompt_unix },

121121

// But passing the same string to eval() should throw

122122

{ client: client_unix, send: 'eval("function test_func() {")',

123-

expect: /^SyntaxError: Unexpected end of input/ },

123+

expect: /\bSyntaxError: Unexpected end of input/ },

124124

// Can handle multiline template literals

125125

{ client: client_unix, send: '`io.js',

126126

expect: prompt_multiline },

@@ -149,35 +149,35 @@ function error_test() {

149149

// invalid input to JSON.parse error is special case of syntax error,

150150

// should throw

151151

{ client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',

152-

expect: /^SyntaxError: Unexpected token i/ },

152+

expect: /\bSyntaxError: Unexpected token i/ },

153153

// end of input to JSON.parse error is special case of syntax error,

154154

// should throw

155155

{ client: client_unix, send: 'JSON.parse(\'066\');',

156-

expect: /^SyntaxError: Unexpected number/ },

156+

expect: /\bSyntaxError: Unexpected number/ },

157157

// should throw

158158

{ client: client_unix, send: 'JSON.parse(\'{\');',

159-

expect: /^SyntaxError: Unexpected end of JSON input/ },

159+

expect: /\bSyntaxError: Unexpected end of JSON input/ },

160160

// invalid RegExps are a special case of syntax error,

161161

// should throw

162162

{ client: client_unix, send: '/(/;',

163-

expect: /^SyntaxError: Invalid regular expression\:/ },

163+

expect: /\bSyntaxError: Invalid regular expression\:/ },

164164

// invalid RegExp modifiers are a special case of syntax error,

165165

// should throw (GH-4012)

166166

{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',

167-

expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ },

167+

expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ },

168168

// strict mode syntax errors should be caught (GH-5178)

169169

{ client: client_unix, send: '(function() { "use strict"; return 0755; })()',

170-

expect: /^SyntaxError: Octal literals are not allowed in strict mode/ },

170+

expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ },

171171

{ client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()',

172-

expect: /^SyntaxError: Duplicate parameter name not allowed in this context/ },

172+

expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ },

173173

{ client: client_unix, send: '(function() { "use strict"; with (this) {} })()',

174-

expect: /^SyntaxError: Strict mode code may not include a with statement/ },

174+

expect: /\bSyntaxError: Strict mode code may not include a with statement/ },

175175

{ client: client_unix, send: '(function() { "use strict"; var x; delete x; })()',

176-

expect: /^SyntaxError: Delete of an unqualified identifier in strict mode/ },

176+

expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ },

177177

{ client: client_unix, send: '(function() { "use strict"; eval = 17; })()',

178-

expect: /^SyntaxError: Unexpected eval or arguments in strict mode/ },

178+

expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ },

179179

{ client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()',

180-

expect: /^SyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ },

180+

expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ },

181181

// Named functions can be used:

182182

{ client: client_unix, send: 'function blah() { return 1; }',

183183

expect: prompt_unix },

@@ -228,7 +228,7 @@ function error_test() {

228228

expect: 'Invalid REPL keyword\n' + prompt_unix },

229229

// fail when we are not inside a String and a line continuation is used

230230

{ client: client_unix, send: '[] \\',

231-

expect: /^SyntaxError: Invalid or unexpected token/ },

231+

expect: /\bSyntaxError: Invalid or unexpected token/ },

232232

// do not fail when a String is created with line continuation

233233

{ client: client_unix, send: '\'the\\\nfourth\\\neye\'',

234234

expect: prompt_multiline + prompt_multiline +

@@ -327,12 +327,18 @@ function error_test() {

327327

// Illegal token is not recoverable outside string literal, RegExp literal,

328328

// or block comment. https://github.com/nodejs/node/issues/3611

329329

{ client: client_unix, send: 'a = 3.5e',

330-

expect: /^SyntaxError: Invalid or unexpected token/ },

330+

expect: /\bSyntaxError: Invalid or unexpected token/ },

331331

// Mitigate https://github.com/nodejs/node/issues/548

332332

{ client: client_unix, send: 'function name(){ return "node"; };name()',

333333

expect: "'node'\n" + prompt_unix },

334334

{ client: client_unix, send: 'function name(){ return "nodejs"; };name()',

335335

expect: "'nodejs'\n" + prompt_unix },

336+

// Avoid emitting repl:line-number for SyntaxError

337+

{ client: client_unix, send: 'a = 3.5e',

338+

expect: /^(?!repl)/ },

339+

// Avoid emitting stack trace

340+

{ client: client_unix, send: 'a = 3.5e',

341+

expect: /^(?!\s+at\s)/gm },

336342

]);

337343

}

338344