summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Schwartz <dennis@repositive.io>2016-09-17 11:40:08 +0200
committerIlkka Myller <ilkka.myller@nodefield.com>2016-09-19 23:33:56 +0300
commit366495d4e221ccd7080a0a05ce67160905b4a6a5 (patch)
tree49b745ba1346292f7daa612a52748182e7d30af0
parent626a07df5bae2b32f88863edb9f4404b42de1ad6 (diff)
downloadandroid-node-v8-366495d4e221ccd7080a0a05ce67160905b4a6a5.tar.gz
android-node-v8-366495d4e221ccd7080a0a05ce67160905b4a6a5.tar.bz2
android-node-v8-366495d4e221ccd7080a0a05ce67160905b4a6a5.zip
test: improve child_process tests
Replaced var keyword with const and let in the tests for child process stdin and stdio. PR-URL: https://github.com/nodejs/node/pull/8617 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
-rw-r--r--test/parallel/test-child-process-stdin.js10
-rw-r--r--test/parallel/test-child-process-stdio-big-write-end.js16
-rw-r--r--test/parallel/test-child-process-stdio.js8
3 files changed, 17 insertions, 17 deletions
diff --git a/test/parallel/test-child-process-stdin.js b/test/parallel/test-child-process-stdin.js
index f30ad83c38..95be2d4c8a 100644
--- a/test/parallel/test-child-process-stdin.js
+++ b/test/parallel/test-child-process-stdin.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
-var cat = spawn(common.isWindows ? 'more' : 'cat');
+const cat = spawn(common.isWindows ? 'more' : 'cat');
cat.stdin.write('hello');
cat.stdin.write(' ');
cat.stdin.write('world');
@@ -14,7 +14,7 @@ assert.ok(!cat.stdin.readable);
cat.stdin.end();
-var response = '';
+let response = '';
cat.stdout.setEncoding('utf8');
cat.stdout.on('data', function(chunk) {
diff --git a/test/parallel/test-child-process-stdio-big-write-end.js b/test/parallel/test-child-process-stdio-big-write-end.js
index 8a5afafdcd..4b0f9d2cf3 100644
--- a/test/parallel/test-child-process-stdio-big-write-end.js
+++ b/test/parallel/test-child-process-stdio-big-write-end.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var BUFSIZE = 1024;
+const assert = require('assert');
+const BUFSIZE = 1024;
switch (process.argv[2]) {
case undefined:
@@ -13,11 +13,11 @@ switch (process.argv[2]) {
}
function parent() {
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child']);
- var sent = 0;
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child']);
+ let sent = 0;
- var n = '';
+ let n = '';
child.stdout.setEncoding('ascii');
child.stdout.on('data', function(c) {
n += c;
@@ -34,7 +34,7 @@ function parent() {
} while (child.stdin.write(buf));
// then write a bunch more times.
- for (var i = 0; i < 100; i++) {
+ for (let i = 0; i < 100; i++) {
const buf = Buffer.alloc(BUFSIZE, '.');
sent += BUFSIZE;
child.stdin.write(buf);
@@ -47,7 +47,7 @@ function parent() {
}
function child() {
- var received = 0;
+ let received = 0;
process.stdin.on('data', function(c) {
received += c.length;
});
diff --git a/test/parallel/test-child-process-stdio.js b/test/parallel/test-child-process-stdio.js
index 2daa748371..e24987ca64 100644
--- a/test/parallel/test-child-process-stdio.js
+++ b/test/parallel/test-child-process-stdio.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var options = {stdio: ['pipe']};
-var child = common.spawnPwd(options);
+let options = {stdio: ['pipe']};
+let child = common.spawnPwd(options);
assert.notEqual(child.stdout, null);
assert.notEqual(child.stderr, null);