@@ -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 : / ^ 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 / } ,
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 : / ^ 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 / } ,
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 : / ^ 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 / } ,
157157 // should throw
158158 { 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 / } ,
160160 // invalid RegExps are a special case of syntax error,
161161 // should throw
162162 { 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 \: / } ,
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 : / ^ 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 / } ,
168168 // strict mode syntax errors should be caught (GH-5178)
169169 { 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 / } ,
171171 { 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 / } ,
173173 { 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 / } ,
175175 { 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 / } ,
177177 { 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 / } ,
179179 { 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 m m e d i a t e l y w i t h i n a n o t h e r f u n c t i o n / } ,
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 m m e d i a t e l y w i t h i n a n o t h e r f u n c t i o n / } ,
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 : / ^ 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 L L E G A L / } ,
231+ 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 L L E G A L / } ,
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 : / ^ 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 L L E G A L / } ,
330+ 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 L L E G A L / } ,
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 : / ^ (? ! r e p l ) / } ,
339+ // Avoid emitting stack trace
340+ { client : client_unix , send : 'a = 3.5e' ,
341+ expect : / ^ (? ! \s + a t \s ) / gm } ,
336342 ] ) ;
337343}
338344
0 commit comments