blob: 2d62d639077634530c3a2fb3c68cfad17a0e46d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
'use strict';
require('../common');
var R = require('_stream_readable');
var W = require('_stream_writable');
var assert = require('assert');
var util = require('util');
var ondataCalled = 0;
function TestReader() {
R.apply(this);
this._buffer = new Buffer(100);
this._buffer.fill('x');
this.on('data', function() {
ondataCalled++;
});
}
util.inherits(TestReader, R);
TestReader.prototype._read = function(n) {
this.push(this._buffer);
this._buffer = new Buffer(0);
};
var reader = new TestReader();
setImmediate(function() {
assert.equal(ondataCalled, 1);
console.log('ok');
reader.push(null);
});
function TestWriter() {
W.apply(this);
this.write('foo');
this.end();
}
util.inherits(TestWriter, W);
TestWriter.prototype._write = function(chunk, enc, cb) {
cb();
};
var writer = new TestWriter();
process.on('exit', function() {
assert.strictEqual(reader.readable, false);
assert.strictEqual(writer.writable, false);
console.log('ok');
});
|