@@ -120,7 +120,7 @@ function error_test() {
120
120
expect : prompt_unix } ,
121
121
// But passing the same string to eval() should throw
122
122
{ client : client_unix , send : 'eval("function test_func() {")' ,
123
- expect : / ^ S y n t a x E r r o r : U n e x p e c t e d e n d o f i n p u t / } ,
123
+ expect : / \b S y n t a x E r r o r : U n e x p e c t e d e n d o f i n p u t / } ,
124
124
// Can handle multiline template literals
125
125
{ client : client_unix , send : '`io.js' ,
126
126
expect : prompt_multiline } ,
@@ -149,35 +149,35 @@ function error_test() {
149
149
// invalid input to JSON.parse error is special case of syntax error,
150
150
// should throw
151
151
{ client : client_unix , send : 'JSON.parse(\'{invalid: \\\'json\\\'}\');' ,
152
- expect : / ^ S y n t a x E r r o r : U n e x p e c t e d t o k e n i / } ,
152
+ expect : / \b S y n t a x E r r o r : U n e x p e c t e d t o k e n i / } ,
153
153
// end of input to JSON.parse error is special case of syntax error,
154
154
// should throw
155
155
{ client : client_unix , send : 'JSON.parse(\'066\');' ,
156
- expect : / ^ S y n t a x E r r o r : U n e x p e c t e d n u m b e r / } ,
156
+ expect : / \b S y n t a x E r r o r : U n e x p e c t e d n u m b e r / } ,
157
157
// should throw
158
158
{ client : client_unix , send : 'JSON.parse(\'{\');' ,
159
- expect : / ^ S y n t a x E r r o r : U n e x p e c t e d e n d o f J S O N i n p u t / } ,
159
+ expect : / \b S y n t a x E r r o r : U n e x p e c t e d e n d o f J S O N i n p u t / } ,
160
160
// invalid RegExps are a special case of syntax error,
161
161
// should throw
162
162
{ client : client_unix , send : '/(/;' ,
163
- expect : / ^ S y n t a x E r r o r : I n v a l i d r e g u l a r e x p r e s s i o n \: / } ,
163
+ expect : / \b S y n t a x E r r o r : I n v a l i d r e g u l a r e x p r e s s i o n \: / } ,
164
164
// invalid RegExp modifiers are a special case of syntax error,
165
165
// should throw (GH-4012)
166
166
{ client : client_unix , send : 'new RegExp("foo", "wrong modifier");' ,
167
- expect : / ^ S y n t a x E r r o r : I n v a l i d f l a g s s u p p l i e d t o R e g E x p c o n s t r u c t o r / } ,
167
+ expect : / \b S y n t a x E r r o r : I n v a l i d f l a g s s u p p l i e d t o R e g E x p c o n s t r u c t o r / } ,
168
168
// strict mode syntax errors should be caught (GH-5178)
169
169
{ client : client_unix , send : '(function() { "use strict"; return 0755; })()' ,
170
- expect : / ^ S y n t a x E r r o r : O c t a l l i t e r a l s a r e n o t a l l o w e d i n s t r i c t m o d e / } ,
170
+ expect : / \b S y n t a x E r r o r : O c t a l l i t e r a l s a r e n o t a l l o w e d i n s t r i c t m o d e / } ,
171
171
{ client : client_unix , send : '(function(a, a, b) { "use strict"; return a + b + c; })()' ,
172
- expect : / ^ S y n t a x E r r o r : D u p l i c a t e p a r a m e t e r n a m e n o t a l l o w e d i n t h i s c o n t e x t / } ,
172
+ expect : / \b S y n t a x E r r o r : D u p l i c a t e p a r a m e t e r n a m e n o t a l l o w e d i n t h i s c o n t e x t / } ,
173
173
{ client : client_unix , send : '(function() { "use strict"; with (this) {} })()' ,
174
- expect : / ^ S y n t a x E r r o r : S t r i c t m o d e c o d e m a y n o t i n c l u d e a w i t h s t a t e m e n t / } ,
174
+ expect : / \b S y n t a x E r r o r : S t r i c t m o d e c o d e m a y n o t i n c l u d e a w i t h s t a t e m e n t / } ,
175
175
{ client : client_unix , send : '(function() { "use strict"; var x; delete x; })()' ,
176
- expect : / ^ S y n t a x E r r o r : D e l e t e o f a n u n q u a l i f i e d i d e n t i f i e r i n s t r i c t m o d e / } ,
176
+ expect : / \b S y n t a x E r r o r : D e l e t e o f a n u n q u a l i f i e d i d e n t i f i e r i n s t r i c t m o d e / } ,
177
177
{ client : client_unix , send : '(function() { "use strict"; eval = 17; })()' ,
178
- expect : / ^ S y n t a x E r r o r : U n e x p e c t e d e v a l o r a r g u m e n t s i n s t r i c t m o d e / } ,
178
+ expect : / \b S y n t a x E r r o r : U n e x p e c t e d e v a l o r a r g u m e n t s i n s t r i c t m o d e / } ,
179
179
{ client : client_unix , send : '(function() { "use strict"; if (true) function f() { } })()' ,
180
- expect : / ^ S y n t a x E r r o r : I n s t r i c t m o d e c o d e , f u n c t i o n s c a n o n l y b e d e c l a r e d a t t o p l e v e l o r i n s i d e a b l o c k ./ } ,
180
+ expect : / \b S y n t a x E r r o r : I n s t r i c t m o d e c o d e , f u n c t i o n s c a n o n l y b e d e c l a r e d a t t o p l e v e l o r i n s i d e a b l o c k ./ } ,
181
181
// Named functions can be used:
182
182
{ client : client_unix , send : 'function blah() { return 1; }' ,
183
183
expect : prompt_unix } ,
@@ -228,7 +228,7 @@ function error_test() {
228
228
expect : 'Invalid REPL keyword\n' + prompt_unix } ,
229
229
// fail when we are not inside a String and a line continuation is used
230
230
{ client : client_unix , send : '[] \\' ,
231
- expect : / ^ S y n t a x E r r o r : I n v a l i d o r u n e x p e c t e d t o k e n / } ,
231
+ expect : / \b S y n t a x E r r o r : I n v a l i d o r u n e x p e c t e d t o k e n / } ,
232
232
// do not fail when a String is created with line continuation
233
233
{ client : client_unix , send : '\'the\\\nfourth\\\neye\'' ,
234
234
expect : prompt_multiline + prompt_multiline +
@@ -327,12 +327,18 @@ function error_test() {
327
327
// Illegal token is not recoverable outside string literal, RegExp literal,
328
328
// or block comment. https://github.com/nodejs/node/issues/3611
329
329
{ client : client_unix , send : 'a = 3.5e' ,
330
- expect : / ^ S y n t a x E r r o r : I n v a l i d o r u n e x p e c t e d t o k e n / } ,
330
+ expect : / \b S y n t a x E r r o r : I n v a l i d o r u n e x p e c t e d t o k e n / } ,
331
331
// Mitigate https://github.com/nodejs/node/issues/548
332
332
{ client : client_unix , send : 'function name(){ return "node"; };name()' ,
333
333
expect : "'node'\n" + prompt_unix } ,
334
334
{ client : client_unix , send : 'function name(){ return "nodejs"; };name()' ,
335
335
expect : "'nodejs'\n" + prompt_unix } ,
336
+ // Avoid emitting repl:line-number for SyntaxError
337
+ { client : client_unix , send : 'a = 3.5e' ,
338
+ expect : / ^ (? ! r e p l ) / } ,
339
+ // Avoid emitting stack trace
340
+ { client : client_unix , send : 'a = 3.5e' ,
341
+ expect : / ^ (? ! \s + a t \s ) / gm } ,
336
342
] ) ;
337
343
}
338
344
0 commit comments