2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-27 21:43:44 -05:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
2012-05-26 15:28:35 +02:00
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
const emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
2012-05-26 15:28:35 +02:00
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
2012-05-26 15:28:35 +02:00
|
|
|
assert.ifError(error);
|
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
const read = fs.createReadStream(emptyFile, { 'fd': fd });
|
2012-05-26 15:28:35 +02:00
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
read.once('data', () => {
|
2012-12-04 17:34:17 -08:00
|
|
|
throw new Error('data event should not emit');
|
2012-05-26 15:28:35 +02:00
|
|
|
});
|
|
|
|
|
2015-12-30 14:02:28 -08:00
|
|
|
read.once('end', common.mustCall(function endEvent1() {}));
|
2016-12-27 21:43:44 -05:00
|
|
|
}));
|
2012-05-26 15:28:35 +02:00
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
2012-05-26 15:28:35 +02:00
|
|
|
assert.ifError(error);
|
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
const read = fs.createReadStream(emptyFile, { 'fd': fd });
|
2012-05-26 15:28:35 +02:00
|
|
|
read.pause();
|
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
read.once('data', () => {
|
2012-12-04 17:34:17 -08:00
|
|
|
throw new Error('data event should not emit');
|
2012-05-26 15:28:35 +02:00
|
|
|
});
|
|
|
|
|
2015-12-30 14:02:28 -08:00
|
|
|
read.once('end', function endEvent2() {
|
|
|
|
throw new Error('end event should not emit');
|
2012-05-26 15:28:35 +02:00
|
|
|
});
|
|
|
|
|
2016-12-27 21:43:44 -05:00
|
|
|
setTimeout(common.mustCall(() => {
|
|
|
|
assert.strictEqual(read.isPaused(), true);
|
|
|
|
}), common.platformTimeout(50));
|
|
|
|
}));
|