Skip to content

Commit

Permalink
test: refactor test-stdin-script-child
Browse files Browse the repository at this point in the history
- 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 <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
  • Loading branch information
emanuelbuholzer authored and italoacasas committed Dec 23, 2016
1 parent f368eee commit bc57f24
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/parallel/test-stdin-script-child.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [], {
const spawn = require('child_process').spawn;
const child = spawn(process.execPath, [], {
env: Object.assign(process.env, {
NODE_DEBUG: process.argv[2]
})
});
var wanted = child.pid + '\n';
const wanted = child.pid + '\n';
var found = '';

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

child.on('close', function(c) {
assert(!c);
assert.equal(found, wanted);
child.on('close', common.mustCall(function(c) {
assert.strictEqual(c, 0);
assert.strictEqual(found, wanted);
console.log('ok');
});
}));

setTimeout(function() {
child.stdin.end('console.log(process.pid)');
});
}, 1);

0 comments on commit bc57f24

Please sign in to comment.