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:
parent
ddc3278313
commit
5bac9ec725
@ -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 {
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user