1
0
mirror of https://github.com/danog/file.git synced 2024-11-26 11:54:54 +01:00

Fix eof logic and remove seek tests for ParallelHandle

This commit is contained in:
Aaron Piotrowski 2017-07-06 16:51:20 -05:00
parent ddc3278313
commit 5bac9ec725
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 1 additions and 35 deletions

View File

@ -96,7 +96,7 @@ class ParallelHandle implements Handle {
* {@inheritdoc}
*/
public function eof(): bool {
return $this->pendingWrites > 0 && $this->size <= $this->position;
return $this->pendingWrites === 0 && $this->size <= $this->position;
}
public function read(int $length = self::DEFAULT_READ_LENGTH): Promise {

View File

@ -19,38 +19,4 @@ class ParallelHandleTest extends AsyncHandleTest {
yield $pool->shutdown();
});
}
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testSimultaneousSeeks() {
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");
$promise1 = $handle->seek(0);
$promise2 = $handle->seek(10);
$this->assertSame(0, yield $promise1);
yield $promise2;
});
}
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testReadWhileSeeking() {
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");
$promise1 = $handle->seek(0);
$promise2 = $handle->read();
$this->assertSame(0, yield $promise1);
yield $promise2;
});
}
}