mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
48 lines
1.0 KiB
13 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var path = require('path');
|
||
|
var fs = require('fs');
|
||
|
|
||
|
var emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
||
|
|
||
|
fs.open(emptyFile, 'r', function (error, fd) {
|
||
|
assert.ifError(error);
|
||
|
|
||
|
var read = fs.createReadStream(emptyFile, { 'fd': fd });
|
||
|
|
||
|
read.once('data', function () {
|
||
12 years ago
|
throw new Error('data event should not emit');
|
||
13 years ago
|
});
|
||
|
|
||
|
var readEmit = false;
|
||
|
read.once('end', function () {
|
||
|
readEmit = true;
|
||
12 years ago
|
console.error('end event 1');
|
||
13 years ago
|
});
|
||
|
|
||
|
setTimeout(function () {
|
||
|
assert.equal(readEmit, true);
|
||
|
}, 50);
|
||
|
});
|
||
|
|
||
|
fs.open(emptyFile, 'r', function (error, fd) {
|
||
|
assert.ifError(error);
|
||
|
|
||
|
var read = fs.createReadStream(emptyFile, { 'fd': fd });
|
||
|
read.pause();
|
||
|
|
||
|
read.once('data', function () {
|
||
12 years ago
|
throw new Error('data event should not emit');
|
||
13 years ago
|
});
|
||
|
|
||
|
var readEmit = false;
|
||
|
read.once('end', function () {
|
||
|
readEmit = true;
|
||
12 years ago
|
console.error('end event 2');
|
||
13 years ago
|
});
|
||
|
|
||
|
setTimeout(function () {
|
||
|
assert.equal(readEmit, false);
|
||
|
}, 50);
|
||
|
});
|