Skip to content

Commit 41567ee

Browse files
sivaprsjasnell
authored andcommitted
test: refactor the code in test-child-process-spawn-loop.js
* use const and let instead of var * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10605 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b9abeec commit 41567ee

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/pummel/test-child-process-spawn-loop.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ const assert = require('assert');
44

55
const spawn = require('child_process').spawn;
66

7-
var SIZE = 1000 * 1024;
8-
var N = 40;
9-
var finished = false;
7+
const SIZE = 1000 * 1024;
8+
const N = 40;
9+
let finished = false;
1010

1111
function doSpawn(i) {
12-
var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
13-
var count = 0;
12+
const child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
13+
let count = 0;
1414

1515
child.stdout.setEncoding('ascii');
16-
child.stdout.on('data', function(chunk) {
16+
child.stdout.on('data', (chunk) => {
1717
count += chunk.length;
1818
});
1919

20-
child.stderr.on('data', function(chunk) {
20+
child.stderr.on('data', (chunk) => {
2121
console.log('stderr: ' + chunk);
2222
});
2323

24-
child.on('close', function() {
24+
child.on('close', () => {
2525
// + 1 for \n or + 2 for \r\n on Windows
26-
assert.equal(SIZE + (common.isWindows ? 2 : 1), count);
26+
assert.strictEqual(SIZE + (common.isWindows ? 2 : 1), count);
2727
if (i < N) {
2828
doSpawn(i + 1);
2929
} else {
@@ -34,6 +34,6 @@ function doSpawn(i) {
3434

3535
doSpawn(0);
3636

37-
process.on('exit', function() {
37+
process.on('exit', () => {
3838
assert.ok(finished);
3939
});

0 commit comments

Comments
 (0)