-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/*<replacement>*/ | ||
var bufferShim = require('safe-buffer').Buffer; | ||
/*</replacement>*/ | ||
var common = require('../common'); | ||
var assert = require('assert/'); | ||
|
||
var _require = require('../../'), | ||
Writable = _require.Writable, | ||
Readable = _require.Readable; | ||
|
||
class NullWriteable extends Writable { | ||
_write(chunk, encoding, callback) { | ||
return callback(); | ||
} | ||
} | ||
class QuickEndReadable extends Readable { | ||
_read() { | ||
this.push(null); | ||
} | ||
} | ||
class NeverEndReadable extends Readable { | ||
_read() {} | ||
} | ||
|
||
function noop() {} | ||
|
||
{ | ||
var dest = new NullWriteable(); | ||
var src = new QuickEndReadable(); | ||
dest.on('pipe', common.mustCall(noop)); | ||
dest.on('unpipe', common.mustCall(noop)); | ||
src.pipe(dest); | ||
setImmediate(function () { | ||
assert.strictEqual(src._readableState.pipesCount, 0); | ||
}); | ||
} | ||
|
||
{ | ||
var _dest = new NullWriteable(); | ||
var _src = new NeverEndReadable(); | ||
_dest.on('pipe', common.mustCall(noop)); | ||
_dest.on('unpipe', common.mustNotCall('unpipe should not have been emitted')); | ||
_src.pipe(_dest); | ||
setImmediate(function () { | ||
assert.strictEqual(_src._readableState.pipesCount, 1); | ||
}); | ||
} | ||
|
||
{ | ||
var _dest2 = new NullWriteable(); | ||
var _src2 = new NeverEndReadable(); | ||
_dest2.on('pipe', common.mustCall(noop)); | ||
_dest2.on('unpipe', common.mustCall(noop)); | ||
_src2.pipe(_dest2); | ||
_src2.unpipe(_dest2); | ||
setImmediate(function () { | ||
assert.strictEqual(_src2._readableState.pipesCount, 0); | ||
}); | ||
} | ||
|
||
{ | ||
var _dest3 = new NullWriteable(); | ||
var _src3 = new QuickEndReadable(); | ||
_dest3.on('pipe', common.mustCall(noop)); | ||
_dest3.on('unpipe', common.mustCall(noop)); | ||
_src3.pipe(_dest3, { end: false }); | ||
setImmediate(function () { | ||
assert.strictEqual(_src3._readableState.pipesCount, 0); | ||
}); | ||
} | ||
|
||
{ | ||
var _dest4 = new NullWriteable(); | ||
var _src4 = new NeverEndReadable(); | ||
_dest4.on('pipe', common.mustCall(noop)); | ||
_dest4.on('unpipe', common.mustNotCall('unpipe should not have been emitted')); | ||
_src4.pipe(_dest4, { end: false }); | ||
setImmediate(function () { | ||
assert.strictEqual(_src4._readableState.pipesCount, 1); | ||
}); | ||
} | ||
|
||
{ | ||
var _dest5 = new NullWriteable(); | ||
var _src5 = new NeverEndReadable(); | ||
_dest5.on('pipe', common.mustCall(noop)); | ||
_dest5.on('unpipe', common.mustCall(noop)); | ||
_src5.pipe(_dest5, { end: false }); | ||
_src5.unpipe(_dest5); | ||
setImmediate(function () { | ||
assert.strictEqual(_src5._readableState.pipesCount, 0); | ||
}); | ||
} |