Skip to content

Commit ef133b3

Browse files
TrottMylesBorins
authored andcommittedJul 11, 2017
lib,test: use regular expression literals
Replace RegExp constructors with regular expression literals where possible. PR-URL: #12807 Backport-PR-URL: #13776 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 99da83b commit ef133b3

4 files changed

+8
-10
lines changed
 

‎test/parallel/test-buffer-alloc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ Buffer.poolSize = ps;
984984
assert.throws(() => Buffer.allocUnsafe(10).copy(),
985985
/TypeError: argument should be a Buffer/);
986986

987-
const regErrorMsg = new RegExp('First argument must be a string, Buffer, ' +
988-
'ArrayBuffer, Array, or array-like object.');
987+
const regErrorMsg =
988+
/First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object\./;
989989

990990
assert.throws(() => Buffer.from(), regErrorMsg);
991991
assert.throws(() => Buffer.from(null), regErrorMsg);

‎test/parallel/test-tls-env-bad-extra-ca.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ fork(__filename, opts)
3333
assert.strictEqual(status, 0, 'client did not succeed in connecting');
3434
}))
3535
.on('close', common.mustCall(function() {
36-
assert(stderr.match(new RegExp(
37-
'Warning: Ignoring extra certs from.*no-such-file-exists' +
38-
'.* load failed:.*No such file or directory'
39-
)), stderr);
36+
assert(stderr.match(
37+
/Warning: Ignoring extra certs from.*no-such-file-exists.* load failed:.*No such file or directory/
38+
), stderr);
4039
}))
4140
.stderr.setEncoding('utf8').on('data', function(str) {
4241
stderr += str;

‎test/parallel/test-tls-key-mismatch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if (!common.hasCrypto) {
88
const assert = require('assert');
99
const tls = require('tls');
1010
const fs = require('fs');
11-
const errorMessageRegex = new RegExp('^Error: error:0B080074:x509 ' +
12-
'certificate routines:X509_check_private_key:key values mismatch$');
11+
const errorMessageRegex =
12+
/^Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch$/;
1313

1414
const options = {
1515
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),

‎test/parallel/test-util-inherits.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ require('../common');
44
const assert = require('assert');
55
const inherits = require('util').inherits;
66
const errCheck =
7-
new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
8-
'null or undefined$');
7+
/^TypeError: The super constructor to "inherits" must not be null or undefined$/;
98

109

1110
// super constructor

0 commit comments

Comments
 (0)
Please sign in to comment.