Skip to content

Commit ad664ea

Browse files
thelostone-mcrefack
authored andcommitted
test: mitigate RegEx exceeding 80 chars
Format commit wrapping lines containing RegEx and exceeding 80 chars. PR-URL: #14607 Fixes: #14586 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 0f325aa commit ad664ea

File tree

6 files changed

+33
-25
lines changed

6 files changed

+33
-25
lines changed

test/addons-napi/test_properties/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
const common = require('../../common');
33
const assert = require('assert');
4-
const readonlyErrorRE = /^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/;
4+
const readonlyErrorRE =
5+
/^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/;
56

67
// Testing api calls for defining properties
78
const test_object = require(`./build/${common.buildType}/test_properties`);

test/parallel/test-process-versions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ assert(commonTemplate.test(process.versions.node));
2929
assert(commonTemplate.test(process.versions.uv));
3030
assert(commonTemplate.test(process.versions.zlib));
3131

32-
assert(/^\d+\.\d+\.\d+(?:\.\d+)?(?: \(candidate\))?$/.test(process.versions.v8));
32+
assert(/^\d+\.\d+\.\d+(?:\.\d+)?(?: \(candidate\))?$/
33+
.test(process.versions.v8));
3334
assert(/^\d+$/.test(process.versions.modules));

test/parallel/test-repl.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function error_test() {
142142
expect: prompt_unix },
143143
// But passing the same string to eval() should throw
144144
{ client: client_unix, send: 'eval("function test_func() {")',
145-
expect: /\bSyntaxError: Unexpected end of input/ },
145+
expect: /^SyntaxError: Unexpected end of input/ },
146146
// Can handle multiline template literals
147147
{ client: client_unix, send: '`io.js',
148148
expect: prompt_multiline },
@@ -171,30 +171,31 @@ function error_test() {
171171
// invalid input to JSON.parse error is special case of syntax error,
172172
// should throw
173173
{ client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
174-
expect: /\bSyntaxError: Unexpected token i/ },
174+
expect: /^SyntaxError: Unexpected token i/ },
175175
// end of input to JSON.parse error is special case of syntax error,
176176
// should throw
177177
{ client: client_unix, send: 'JSON.parse(\'066\');',
178-
expect: /\bSyntaxError: Unexpected number/ },
178+
expect: /^SyntaxError: Unexpected number/ },
179179
// should throw
180180
{ client: client_unix, send: 'JSON.parse(\'{\');',
181-
expect: /\bSyntaxError: Unexpected end of JSON input/ },
181+
expect: /^SyntaxError: Unexpected end of JSON input/ },
182182
// invalid RegExps are a special case of syntax error,
183183
// should throw
184184
{ client: client_unix, send: '/(/;',
185-
expect: /\bSyntaxError: Invalid regular expression:/ },
185+
expect: /^SyntaxError: Invalid regular expression:/ },
186186
// invalid RegExp modifiers are a special case of syntax error,
187187
// should throw (GH-4012)
188188
{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
189-
expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ },
189+
expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ },
190190
// strict mode syntax errors should be caught (GH-5178)
191191
{ client: client_unix,
192192
send: '(function() { "use strict"; return 0755; })()',
193193
expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ },
194194
{
195195
client: client_unix,
196196
send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
197-
expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/
197+
expect:
198+
/\bSyntaxError: Duplicate parameter name not allowed in this context/
198199
},
199200
{
200201
client: client_unix,
@@ -204,15 +205,17 @@ function error_test() {
204205
{
205206
client: client_unix,
206207
send: '(function() { "use strict"; var x; delete x; })()',
207-
expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/
208+
expect:
209+
/\bSyntaxError: Delete of an unqualified identifier in strict mode/
208210
},
209211
{ client: client_unix,
210212
send: '(function() { "use strict"; eval = 17; })()',
211213
expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ },
212214
{
213215
client: client_unix,
214216
send: '(function() { "use strict"; if (true) function f() { } })()',
215-
expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block\./
217+
expect:
218+
/\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block\./
216219
},
217220
// Named functions can be used:
218221
{ client: client_unix, send: 'function blah() { return 1; }',

test/parallel/test-v8-serdes.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const objects = [
2020
circular
2121
];
2222

23+
const serializerTypeError =
24+
/^TypeError: Class constructor Serializer cannot be invoked without 'new'$/;
25+
const deserializerTypeError =
26+
/^TypeError: Class constructor Deserializer cannot be invoked without 'new'$/;
27+
2328
{
2429
const ser = new v8.DefaultSerializer();
2530
ser.writeHeader();
@@ -133,13 +138,6 @@ const objects = [
133138
}
134139

135140
{
136-
assert.throws(
137-
() => { v8.Serializer(); },
138-
/^TypeError: Class constructor Serializer cannot be invoked without 'new'$/
139-
);
140-
141-
assert.throws(
142-
() => { v8.Deserializer(); },
143-
/^TypeError: Class constructor Deserializer cannot be invoked without 'new'$/
144-
);
141+
assert.throws(v8.Serializer, serializerTypeError);
142+
assert.throws(v8.Deserializer, deserializerTypeError);
145143
}

test/parallel/test-whatwg-url-properties.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ assert.strictEqual(url.searchParams, oldParams); // [SameObject]
4343
// searchParams is readonly. Under strict mode setting a
4444
// non-writable property should throw.
4545
// Note: this error message is subject to change in V8 updates
46-
assert.throws(() => url.origin = 'http://foo.bar.com:22',
47-
/TypeError: Cannot set property origin of \[object URL\] which has only a getter$/);
46+
assert.throws(
47+
() => url.origin = 'http://foo.bar.com:22',
48+
/^TypeError: Cannot set property origin of \[object URL\] which has only a getter$/
49+
);
4850
assert.strictEqual(url.origin, 'http://foo.bar.com:21');
4951
assert.strictEqual(url.toString(),
5052
'http://user:[email protected]:21/aaa/zzz?l=25#test');
@@ -118,8 +120,10 @@ assert.strictEqual(url.hash, '#abcd');
118120
// searchParams is readonly. Under strict mode setting a
119121
// non-writable property should throw.
120122
// Note: this error message is subject to change in V8 updates
121-
assert.throws(() => url.searchParams = '?k=88',
122-
/^TypeError: Cannot set property searchParams of \[object URL\] which has only a getter$/);
123+
assert.throws(
124+
() => url.searchParams = '?k=88',
125+
/^TypeError: Cannot set property searchParams of \[object URL\] which has only a getter$/
126+
);
123127
assert.strictEqual(url.searchParams, oldParams);
124128
assert.strictEqual(url.toString(),
125129
'https://user2:[email protected]:23/aaa/bbb?k=99#abcd');

test/parallel/test-zlib-not-string-or-buffer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ require('../common');
77
const assert = require('assert');
88
const zlib = require('zlib');
99

10-
const expected = /^TypeError: "buffer" argument must be a string, Buffer, TypedArray, or DataView$/;
10+
const expected =
11+
/^TypeError: "buffer" argument must be a string, Buffer, TypedArray, or DataView$/;
1112

1213
assert.throws(() => { zlib.deflateSync(undefined); }, expected);
1314
assert.throws(() => { zlib.deflateSync(null); }, expected);

0 commit comments

Comments
 (0)