1- /* eslint-disable max-len */
21'use strict' ;
32
43const common = require ( '../common' ) ;
@@ -168,18 +167,32 @@ function error_test() {
168167 { client : client_unix , send : 'new RegExp("foo", "wrong modifier");' ,
169168 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 / } ,
170169 // strict mode syntax errors should be caught (GH-5178)
171- { client : client_unix , send : '(function() { "use strict"; return 0755; })()' ,
170+ { client : client_unix ,
171+ send : '(function() { "use strict"; return 0755; })()' ,
172172 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 / } ,
173- { client : client_unix , send : '(function(a, a, b) { "use strict"; return a + b + c; })()' ,
174- 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 / } ,
175- { client : client_unix , send : '(function() { "use strict"; with (this) {} })()' ,
176- 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 / } ,
177- { client : client_unix , send : '(function() { "use strict"; var x; delete x; })()' ,
178- 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 / } ,
179- { client : client_unix , send : '(function() { "use strict"; eval = 17; })()' ,
173+ {
174+ client : client_unix ,
175+ send : '(function(a, a, b) { "use strict"; return a + b + c; })()' ,
176+ 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 / // eslint-disable-line max-len
177+ } ,
178+ {
179+ client : client_unix ,
180+ send : '(function() { "use strict"; with (this) {} })()' ,
181+ 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 /
182+ } ,
183+ {
184+ client : client_unix ,
185+ send : '(function() { "use strict"; var x; delete x; })()' ,
186+ 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 / // eslint-disable-line max-len
187+ } ,
188+ { client : client_unix ,
189+ send : '(function() { "use strict"; eval = 17; })()' ,
180190 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 / } ,
181- { client : client_unix , send : '(function() { "use strict"; if (true) function f() { } })()' ,
182- 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 ./ } ,
191+ {
192+ client : client_unix ,
193+ send : '(function() { "use strict"; if (true) function f() { } })()' ,
194+ 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 ./ // eslint-disable-line max-len
195+ } ,
183196 // Named functions can be used:
184197 { client : client_unix , send : 'function blah() { return 1; }' ,
185198 expect : prompt_unix } ,
@@ -312,16 +325,20 @@ function error_test() {
312325 { client : client_unix , send : 'require("internal/repl")' ,
313326 expect : / ^ E r r o r : C a n n o t f i n d m o d u l e ' i n t e r n a l \/ r e p l ' / } ,
314327 // REPL should handle quotes within regexp literal in multiline mode
315- { client : client_unix , send : "function x(s) {\nreturn s.replace(/'/,'');\n}" ,
328+ { client : client_unix ,
329+ send : "function x(s) {\nreturn s.replace(/'/,'');\n}" ,
316330 expect : prompt_multiline + prompt_multiline +
317331 'undefined\n' + prompt_unix } ,
318- { client : client_unix , send : "function x(s) {\nreturn s.replace(/'/,'');\n}" ,
332+ { client : client_unix ,
333+ send : "function x(s) {\nreturn s.replace(/'/,'');\n}" ,
319334 expect : prompt_multiline + prompt_multiline +
320335 'undefined\n' + prompt_unix } ,
321- { client : client_unix , send : 'function x(s) {\nreturn s.replace(/"/,"");\n}' ,
336+ { client : client_unix ,
337+ send : 'function x(s) {\nreturn s.replace(/"/,"");\n}' ,
322338 expect : prompt_multiline + prompt_multiline +
323339 'undefined\n' + prompt_unix } ,
324- { client : client_unix , send : 'function x(s) {\nreturn s.replace(/.*/,"");\n}' ,
340+ { client : client_unix ,
341+ send : 'function x(s) {\nreturn s.replace(/.*/,"");\n}' ,
325342 expect : prompt_multiline + prompt_multiline +
326343 'undefined\n' + prompt_unix } ,
327344 { client : client_unix , send : '{ var x = 4; }' ,
@@ -356,14 +373,20 @@ function error_test() {
356373 expect : '{ value: undefined, done: true }' } ,
357374
358375 // https://github.com/nodejs/node/issues/9300
359- { client : client_unix , send : 'function foo() {\nvar bar = 1 / 1; // "/"\n}' ,
360- expect : prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix } ,
361-
362- { client : client_unix , send : '(function() {\nreturn /foo/ / /bar/;\n}())' ,
363- expect : prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix } ,
364-
365- { client : client_unix , send : '(function() {\nif (false) {} /bar"/;\n}())' ,
366- expect : prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }
376+ {
377+ client : client_unix , send : 'function foo() {\nvar bar = 1 / 1; // "/"\n}' ,
378+ expect : `${ prompt_multiline } ${ prompt_multiline } undefined\n${ prompt_unix } `
379+ } ,
380+
381+ {
382+ client : client_unix , send : '(function() {\nreturn /foo/ / /bar/;\n}())' ,
383+ expect : prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix
384+ } ,
385+
386+ {
387+ client : client_unix , send : '(function() {\nif (false) {} /bar"/;\n}())' ,
388+ expect : prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix
389+ }
367390 ] ) ;
368391}
369392
0 commit comments