summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorJackson Tian <shyvo1987@gmail.com>2017-01-30 16:57:49 +0800
committerItalo A. Casas <me@italoacasas.com>2017-02-01 20:06:04 -0800
commit58dc229d9aac29132cf038ed07b3b7e13b671dca (patch)
tree2b0077284bf4e1f5fa348f799dd780af37a1b93a /test/parallel
parent773cdc31ef3e17327d1eb0a3b92828e25457f015 (diff)
downloadandroid-node-v8-58dc229d9aac29132cf038ed07b3b7e13b671dca.tar.gz
android-node-v8-58dc229d9aac29132cf038ed07b3b7e13b671dca.tar.bz2
android-node-v8-58dc229d9aac29132cf038ed07b3b7e13b671dca.zip
test: use repeat() instead of new Array().join()
The usage of `new Array(length + 1).join(str)` is strange. Change to `str.repeat(length)` is more clearly. PR-URL: https://github.com/nodejs/node/pull/11071 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-buffer-concat.js2
-rw-r--r--test/parallel/test-fs-long-path.js2
-rw-r--r--test/parallel/test-fs-readfile-pipe-large.js2
-rw-r--r--test/parallel/test-fs-readfilesync-pipe-large.js2
-rw-r--r--test/parallel/test-http-byteswritten.js2
-rw-r--r--test/parallel/test-http-pipeline-flood.js2
-rw-r--r--test/parallel/test-http-pipeline-regr-3332.js2
-rw-r--r--test/parallel/test-stream2-writable.js2
-rw-r--r--test/parallel/test-string-decoder-end.js2
9 files changed, 9 insertions, 9 deletions
diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js
index 44dc0ad21d..9a6a08ad62 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 8d22159e24..a85a1b5cb5 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 926cc318c4..f0d1dd9c40 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 e791618b49..01e4104777 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 3b295ebdcc..c92506e827 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 99e4c3e7b5..8c14af7be9 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 b34ad49985..abac05c0bc 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 c377ce9a51..0464ee96e2 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 921a7a138a..d9fe7f8273 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));
}