Skip to content

Commit 7d61bbf

Browse files
emanuelbuholzerMylesBorins
authored andcommitted
test: refactor test-stdin-script-child
- var -> const where possible - assert.equal -> assert.strictEqual - passed the setTimeout function a second parameter for readability - used assert.strictEqual for assert(!c) as it is expected to be 0 and not some other value PR-URL: #10321 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]>
1 parent 76bb3cb commit 7d61bbf

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
2-
require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var spawn = require('child_process').spawn;
6-
var child = spawn(process.execPath, [], {
5+
const spawn = require('child_process').spawn;
6+
const child = spawn(process.execPath, [], {
77
env: Object.assign(process.env, {
88
NODE_DEBUG: process.argv[2]
99
})
1010
});
11-
var wanted = child.pid + '\n';
11+
const wanted = child.pid + '\n';
1212
var found = '';
1313

1414
child.stdout.setEncoding('utf8');
@@ -21,12 +21,12 @@ child.stderr.on('data', function(c) {
2121
console.error('> ' + c.trim().split(/\n/).join('\n> '));
2222
});
2323

24-
child.on('close', function(c) {
25-
assert(!c);
26-
assert.equal(found, wanted);
24+
child.on('close', common.mustCall(function(c) {
25+
assert.strictEqual(c, 0);
26+
assert.strictEqual(found, wanted);
2727
console.log('ok');
28-
});
28+
}));
2929

3030
setTimeout(function() {
3131
child.stdin.end('console.log(process.pid)');
32-
});
32+
}, 1);

0 commit comments

Comments
 (0)