diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 420010e1a3d6c9..3cf1b52e6179f2 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -1,4 +1,3 @@ -/* eslint-disable max-len */ 'use strict'; const common = require('../common'); @@ -168,18 +167,32 @@ function error_test() { { client: client_unix, send: 'new RegExp("foo", "wrong modifier");', expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ }, // strict mode syntax errors should be caught (GH-5178) - { client: client_unix, send: '(function() { "use strict"; return 0755; })()', + { client: client_unix, + send: '(function() { "use strict"; return 0755; })()', expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ }, - { client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()', - expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ }, - { client: client_unix, send: '(function() { "use strict"; with (this) {} })()', - expect: /\bSyntaxError: Strict mode code may not include a with statement/ }, - { client: client_unix, send: '(function() { "use strict"; var x; delete x; })()', - expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; eval = 17; })()', + { + client: client_unix, + send: '(function(a, a, b) { "use strict"; return a + b + c; })()', + expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ // eslint-disable-line max-len + }, + { + client: client_unix, + send: '(function() { "use strict"; with (this) {} })()', + expect: /\bSyntaxError: Strict mode code may not include a with statement/ + }, + { + client: client_unix, + send: '(function() { "use strict"; var x; delete x; })()', + expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ // eslint-disable-line max-len + }, + { client: client_unix, + send: '(function() { "use strict"; eval = 17; })()', expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()', - expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ }, + { + client: client_unix, + send: '(function() { "use strict"; if (true) function f() { } })()', + expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ // eslint-disable-line max-len + }, // Named functions can be used: { client: client_unix, send: 'function blah() { return 1; }', expect: prompt_unix }, @@ -312,16 +325,20 @@ function error_test() { { client: client_unix, send: 'require("internal/repl")', expect: /^Error: Cannot find module 'internal\/repl'/ }, // REPL should handle quotes within regexp literal in multiline mode - { client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}", + { client: client_unix, + send: "function x(s) {\nreturn s.replace(/'/,'');\n}", expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}", + { client: client_unix, + send: "function x(s) {\nreturn s.replace(/'/,'');\n}", expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: 'function x(s) {\nreturn s.replace(/"/,"");\n}', + { client: client_unix, + send: 'function x(s) {\nreturn s.replace(/"/,"");\n}', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}', + { client: client_unix, + send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, { client: client_unix, send: '{ var x = 4; }', @@ -356,14 +373,20 @@ function error_test() { expect: '{ value: undefined, done: true }' }, // https://github.com/nodejs/node/issues/9300 - { client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}', - expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - - { client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())', - expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix }, - - { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', - expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix } + { + client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}', + expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}` + }, + + { + client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())', + expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix + }, + + { + client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', + expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix + } ]); }