diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js index 5d558835b7db83..ab47c5643b88fa 100644 --- a/test/parallel/test-buffer-concat.js +++ b/test/parallel/test-buffer-concat.js @@ -15,7 +15,7 @@ const flatLongLen = Buffer.concat(long, 40); assert.strictEqual(flatZero.length, 0); assert.strictEqual(flatOne.toString(), 'asdf'); -const check = new Array(10 + 1).join('asdf'); +const check = 'asdf'.repeat(10); // A special case where concat used to return the first item, // if the length is one. This check is to make sure that we don't do that. diff --git a/test/parallel/test-fs-long-path.js b/test/parallel/test-fs-long-path.js index 8d22159e24bd79..a85a1b5cb52fa1 100644 --- a/test/parallel/test-fs-long-path.js +++ b/test/parallel/test-fs-long-path.js @@ -11,7 +11,7 @@ if (!common.isWindows) { // make a path that will be at least 260 chars long. const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1); -const fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); +const fileName = path.join(common.tmpDir, 'x'.repeat(fileNameLen)); const fullPath = path.resolve(fileName); common.refreshTmpDir(); diff --git a/test/parallel/test-fs-readfile-pipe-large.js b/test/parallel/test-fs-readfile-pipe-large.js index 926cc318c4f63a..f0d1dd9c408610 100644 --- a/test/parallel/test-fs-readfile-pipe-large.js +++ b/test/parallel/test-fs-readfile-pipe-large.js @@ -21,7 +21,7 @@ if (process.argv[2] === 'child') { } const filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt'); -const dataExpected = new Array(1000000).join('a'); +const dataExpected = 'a'.repeat(999999); common.refreshTmpDir(); fs.writeFileSync(filename, dataExpected); diff --git a/test/parallel/test-fs-readfilesync-pipe-large.js b/test/parallel/test-fs-readfilesync-pipe-large.js index e791618b4999fe..01e41047774c9b 100644 --- a/test/parallel/test-fs-readfilesync-pipe-large.js +++ b/test/parallel/test-fs-readfilesync-pipe-large.js @@ -18,7 +18,7 @@ if (process.argv[2] === 'child') { } const filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt'); -const dataExpected = new Array(1000000).join('a'); +const dataExpected = 'a'.repeat(999999); common.refreshTmpDir(); fs.writeFileSync(filename, dataExpected); diff --git a/test/parallel/test-http-byteswritten.js b/test/parallel/test-http-byteswritten.js index 3b295ebdcc1c49..c92506e82717f4 100644 --- a/test/parallel/test-http-byteswritten.js +++ b/test/parallel/test-http-byteswritten.js @@ -16,7 +16,7 @@ const httpServer = http.createServer(common.mustCall(function(req, res) { // Write 1.5mb to cause some requests to buffer // Also, mix up the encodings a bit. - const chunk = new Array(1024 + 1).join('7'); + const chunk = '7'.repeat(1024); const bchunk = Buffer.from(chunk); for (let i = 0; i < 1024; i++) { res.write(chunk); diff --git a/test/parallel/test-http-pipeline-flood.js b/test/parallel/test-http-pipeline-flood.js index 99e4c3e7b5b9fe..8c14af7be9fb0a 100644 --- a/test/parallel/test-http-pipeline-flood.js +++ b/test/parallel/test-http-pipeline-flood.js @@ -70,7 +70,7 @@ function child() { let req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`; - req = new Array(10241).join(req); + req = req.repeat(10240); conn.on('connect', write); diff --git a/test/parallel/test-http-pipeline-regr-3332.js b/test/parallel/test-http-pipeline-regr-3332.js index b34ad499850b70..abac05c0bc0854 100644 --- a/test/parallel/test-http-pipeline-regr-3332.js +++ b/test/parallel/test-http-pipeline-regr-3332.js @@ -19,7 +19,7 @@ const server = http.createServer(function(req, res) { } }); }).listen(0, function() { - const req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n'); + const req = 'GET / HTTP/1.1\r\n\r\n'.repeat(COUNT); client = net.connect(this.address().port, function() { client.write(req); }); diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index c377ce9a510caa..0464ee96e2f795 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -24,7 +24,7 @@ TestWriter.prototype._write = function(chunk, encoding, cb) { const chunks = new Array(50); for (let i = 0; i < chunks.length; i++) { - chunks[i] = new Array(i + 1).join('x'); + chunks[i] = 'x'.repeat(i); } // tiny node-tap lookalike. diff --git a/test/parallel/test-string-decoder-end.js b/test/parallel/test-string-decoder-end.js index 6e9eea3193e163..399f78099268d3 100644 --- a/test/parallel/test-string-decoder-end.js +++ b/test/parallel/test-string-decoder-end.js @@ -12,7 +12,7 @@ const bufs = [ '☃💩', 'asdf' ].map((b) => Buffer.from(b)); // also test just arbitrary bytes from 0-15. for (let i = 1; i <= 16; i++) { - const bytes = new Array(i).join('.').split('.').map((_, j) => j + 0x78); + const bytes = '.'.repeat(i - 1).split('.').map((_, j) => j + 0x78); bufs.push(Buffer.from(bytes)); } diff --git a/test/pummel/test-tls-server-large-request.js b/test/pummel/test-tls-server-large-request.js index 41393120fcd1e2..36fb566fab15d2 100644 --- a/test/pummel/test-tls-server-large-request.js +++ b/test/pummel/test-tls-server-large-request.js @@ -12,7 +12,7 @@ const fs = require('fs'); const stream = require('stream'); const util = require('util'); -const request = Buffer.from(new Array(1024 * 256).join('ABCD')); // 1mb +const request = Buffer.from('ABCD'.repeat(1024 * 256 - 1)); // 1mb const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),