1'use strict';
2// This tests that piping stdin will cause it to resume() as well.
3require('../common');
4const assert = require('assert');
5
6if (process.argv[2] === 'child') {
7  process.stdin.pipe(process.stdout);
8} else {
9  const spawn = require('child_process').spawn;
10  const buffers = [];
11  const child = spawn(process.execPath, [__filename, 'child']);
12  child.stdout.on('data', function(c) {
13    buffers.push(c);
14  });
15  child.stdout.on('close', function() {
16    const b = Buffer.concat(buffers).toString();
17    assert.strictEqual(b, 'Hello, world\n');
18    console.log('ok');
19  });
20  child.stdin.write('Hel');
21  child.stdin.write('lo,');
22  child.stdin.write(' wo');
23  setTimeout(function() {
24    child.stdin.write('rld\n');
25    child.stdin.end();
26  }, 10);
27}
28