<|start_filename|>test/integration/test-recursion-append.js<|end_filename|>
var common = require('../common');
var assert = common.assert;
var CombinedStream = common.CombinedStream;

var s = CombinedStream.create();

for (var i = 0; i < 1e4; i++)
    s.append('test');

// Shouldn't throw "RangeError: Maximum call stack size exceeded"
s.resume();


<|start_filename|>test/integration/test-pipe-memory-leak.js<|end_filename|>
var common = require('../common');
var assert = common.assert;
var CombinedStream = common.CombinedStream;
var fs = require('fs');
var LARGE = common.dir.fixture + '/large.txt';
var FILE1 = common.dir.fixture + '/file1.txt';

var Readable = require('stream').Readable;
var Writable = require('stream').Writable;

var rss = process.memoryUsage().rss;
var ws = Writable();
ws._write = function (chunk, enc, next) {
  setTimeout(function() {
    var rssDiff = process.memoryUsage().rss - rss;
    fs.unlink(LARGE, function(){});
    assert.ok(rssDiff < totalSize);
    process.exit();
    next();
  }, 5000);
  return false;
};

var rs = Readable();
var totalSize = 1024 * 1024 * 500; // 500MB
var readBytes = 0;

rs._read = function(n) {
  var buff = new Buffer(n);
  this.push(buff);
  readBytes += n;
  if (readBytes > totalSize) this.push(null);
};

rs.pipe(fs.createWriteStream(LARGE)).on('finish', function() {
  var combinedStream = CombinedStream.create();
  combinedStream.append(fs.createReadStream(FILE1));
  combinedStream.append(fs.createReadStream(LARGE));

  combinedStream.pipe(ws);
});