Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
A stream should emit "readable" when it gets an EOF but has not yet
passed its highWaterMark.

Re: nodejs#5141
  • Loading branch information
mjackson committed Mar 26, 2013
1 parent e8d179e commit 96f3446
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/simple/test-stream-readable-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,27 @@ var Readable = require('stream').Readable;
console.log('ok 2');
});
})();

(function third() {
// Third test, not reading when the stream has not passed
// the highWaterMark but *has* reached EOF.
var r = new Readable({
highWaterMark: 30
});

// This triggers a 'readable' event, which is lost.
r.push(new Buffer('blerg'));
r.push(null);

var caughtReadable = false;
setTimeout(function() {
r.on('readable', function() {
caughtReadable = true;
});
});

process.on('exit', function() {
assert(caughtReadable);
console.log('ok 3');
});
})();

0 comments on commit 96f3446

Please sign in to comment.