From a23aca4f12003e17745f07962a13bab77d2e9206 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 10 Apr 2017 23:24:47 +0800 Subject: [PATCH] test: replace [].join() with ''.repeat() Replace [].join calls with the more modern .repeat PR-URL: https://github.com/nodejs/node/pull/12305 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Daijiro Wachi Reviewed-By: Alexey Orlenko Reviewed-By: Vse Mozhet Byt Reviewed-By: Yuta Hiroto --- test/parallel/test-child-process-send-utf8.js | 2 +- test/parallel/test-stringbytes-external.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-send-utf8.js b/test/parallel/test-child-process-send-utf8.js index c5d0943301..4cedc589b1 100644 --- a/test/parallel/test-child-process-send-utf8.js +++ b/test/parallel/test-child-process-send-utf8.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const fork = require('child_process').fork; -const expected = Array(1e5).join('ßßßß'); +const expected = 'ßßßß'.repeat(1e5 - 1); if (process.argv[2] === 'child') { process.send(expected); } else { diff --git a/test/parallel/test-stringbytes-external.js b/test/parallel/test-stringbytes-external.js index 94b58d9c6e..3775ecc13e 100644 --- a/test/parallel/test-stringbytes-external.js +++ b/test/parallel/test-stringbytes-external.js @@ -23,9 +23,9 @@ assert.strictEqual(b[1], 0); assert.strictEqual(ucs2_control, c); // now create big strings -const size = 1 + (1 << 20); -write_str = Array(size).join(write_str); -ucs2_control = Array(size).join(ucs2_control); +const size = 1 << 20; +write_str = write_str.repeat(size); +ucs2_control = ucs2_control.repeat(size); // check resultant buffer and output string b = Buffer.from(write_str, 'ucs2'); @@ -110,7 +110,7 @@ const PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; // https://github.com/nodejs/node/issues/1024 { - const a = Array(1 << 20).join('x'); + const a = 'x'.repeat(1 << 20 - 1); const b = Buffer.from(a, 'ucs2').toString('ucs2'); const c = Buffer.from(b, 'utf8').toString('utf8');