Skip to content

Commit ef133b3

Browse files
TrottMylesBorins
authored andcommitted
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 <luigipinca@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 99da83b commit ef133b3

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ Buffer.poolSize = ps;
984984
assert.throws(()=>Buffer.allocUnsafe(10).copy(),
985985
/TypeError:argumentshouldbeaBuffer/);
986986

987-
constregErrorMsg=newRegExp('First argument must be a string, Buffer, '+
988-
'ArrayBuffer, Array, or array-like object.');
987+
constregErrorMsg=
988+
/Firstargumentmustbeastring,Buffer,ArrayBuffer,Array,orarray-likeobject\./;
989989

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

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

Lines changed: 3 additions & 4 deletions
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(newRegExp(
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:Ignoringextracertsfrom.*no-such-file-exists.*loadfailed:.*Nosuchfileordirectory/
38+
),stderr);
4039
}))
4140
.stderr.setEncoding('utf8').on('data',function(str){
4241
stderr+=str;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if (!common.hasCrypto) {
88
constassert=require('assert');
99
consttls=require('tls');
1010
constfs=require('fs');
11-
consterrorMessageRegex=newRegExp('^Error: error:0B080074:x509 '+
12-
'certificate routines:X509_check_private_key:key values mismatch$');
11+
consterrorMessageRegex=
12+
/^Error:error:0B080074:x509certificateroutines:X509_check_private_key:keyvaluesmismatch$/;
1313

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ require('../common');
44
constassert=require('assert');
55
constinherits=require('util').inherits;
66
consterrCheck=
7-
newRegExp('^TypeError: The super constructor to "inherits" must not be '+
8-
'null or undefined$');
7+
/^TypeError:Thesuperconstructorto"inherits"mustnotbenullorundefined$/;
98

109

1110
// super constructor

0 commit comments

Comments
 (0)