Skip to content

Commit

Permalink
test: enable max-len for test-repl
Browse files Browse the repository at this point in the history
Instead of disabling max-len (ESLint's line-length rule) for the entire
file, reformat to avoid exceeding length restrictions in most cases and
disable the rule only on specific lines where exceeding the length
restriction may be a better choice than conforming to it.

PR-URL: #11559
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
  • Loading branch information
Trott committed Mar 2, 2017
1 parent e317a61 commit ebe8c3d
Showing 1 changed file with 46 additions and 23 deletions.
69 changes: 46 additions & 23 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-len */
'use strict';

const common = require('../common');
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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; }',
Expand Down Expand Up @@ -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
}
]);
}

Expand Down

0 comments on commit ebe8c3d

Please sign in to comment.