mirror of
https://github.com/danog/loop.git
synced 2024-11-26 11:54:51 +01:00
Improve coverage
This commit is contained in:
parent
da08301a91
commit
4b2a24e3db
20
lib/Loop.php
20
lib/Loop.php
@ -80,8 +80,20 @@ abstract class Loop implements Stringable
|
||||
if (!$this->running) {
|
||||
return false;
|
||||
}
|
||||
$this->resume();
|
||||
$this->running = false;
|
||||
if ($this->resumeTimer) {
|
||||
$storedWatcherId = $this->resumeTimer;
|
||||
EventLoop::cancel($storedWatcherId);
|
||||
$this->resumeTimer = null;
|
||||
}
|
||||
if ($this->resumeImmediate) {
|
||||
$storedWatcherId = $this->resumeImmediate;
|
||||
EventLoop::cancel($storedWatcherId);
|
||||
$this->resumeTimer = null;
|
||||
}
|
||||
if ($this->paused) {
|
||||
$this->exitedLoop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
abstract protected function loop(): ?float;
|
||||
@ -123,11 +135,7 @@ abstract class Loop implements Stringable
|
||||
private function exitedLoopInternal(): void
|
||||
{
|
||||
$this->running = false;
|
||||
if ($this->resumeTimer) {
|
||||
$storedWatcherId = $this->resumeTimer;
|
||||
EventLoop::cancel($storedWatcherId);
|
||||
$this->resumeTimer = null;
|
||||
}
|
||||
\assert($this->resumeTimer === null);
|
||||
if ($this->resumeImmediate) {
|
||||
$storedWatcherId = $this->resumeImmediate;
|
||||
EventLoop::cancel($storedWatcherId);
|
||||
|
@ -164,7 +164,7 @@ class GenericTest extends AsyncTestCase
|
||||
$this->assertEquals(0.1, $loop->getLastPause());
|
||||
|
||||
$this->assertTrue($loop->resume());
|
||||
delay(0.002);
|
||||
delay(0.003);
|
||||
|
||||
$this->assertEquals(4, $runCount);
|
||||
$this->assertEquals(4, $loop->getPauseCount());
|
||||
@ -181,10 +181,12 @@ class GenericTest extends AsyncTestCase
|
||||
$this->assertEquals(4, $loop->getPauseCount());
|
||||
$this->assertEquals(0.1, $loop->getLastPause());
|
||||
|
||||
$this->assertFalse($loop->isRunning());
|
||||
|
||||
$this->assertEquals(1, $loop->startCounter());
|
||||
$this->assertEquals(1, $loop->endCounter());
|
||||
|
||||
$this->assertFalse($loop->isRunning());
|
||||
$this->assertFalse($loop->stop());
|
||||
$this->assertFalse($loop->resume());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user