Skip to content

Commit

Permalink
lib,test: use regular expression literals
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and MylesBorins committed Jul 11, 2017
1 parent 99da83b commit ef133b3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-alloc.js
Expand Up @@ -984,8 +984,8 @@ Buffer.poolSize = ps;
assert.throws(() => Buffer.allocUnsafe(10).copy(),
/TypeError: argument should be a Buffer/);

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

assert.throws(() => Buffer.from(), regErrorMsg);
assert.throws(() => Buffer.from(null), regErrorMsg);
Expand Down
7 changes: 3 additions & 4 deletions test/parallel/test-tls-env-bad-extra-ca.js
Expand Up @@ -33,10 +33,9 @@ fork(__filename, opts)
assert.strictEqual(status, 0, 'client did not succeed in connecting');
}))
.on('close', common.mustCall(function() {
assert(stderr.match(new RegExp(
'Warning: Ignoring extra certs from.*no-such-file-exists' +
'.* load failed:.*No such file or directory'
)), stderr);
assert(stderr.match(
/Warning: Ignoring extra certs from.*no-such-file-exists.* load failed:.*No such file or directory/
), stderr);
}))
.stderr.setEncoding('utf8').on('data', function(str) {
stderr += str;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-key-mismatch.js
Expand Up @@ -8,8 +8,8 @@ if (!common.hasCrypto) {
const assert = require('assert');
const tls = require('tls');
const fs = require('fs');
const errorMessageRegex = new RegExp('^Error: error:0B080074:x509 ' +
'certificate routines:X509_check_private_key:key values mismatch$');
const errorMessageRegex =
/^Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch$/;

const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-util-inherits.js
Expand Up @@ -4,8 +4,7 @@ require('../common');
const assert = require('assert');
const inherits = require('util').inherits;
const errCheck =
new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
'null or undefined$');
/^TypeError: The super constructor to "inherits" must not be null or undefined$/;


// super constructor
Expand Down

0 comments on commit ef133b3

Please sign in to comment.