Skip to content

Commit a032124

Browse files
Move "testTimerIntervalBelowZeroRunsImmediately" from AbstractLoopTest to AbstractTimerTest
1 parent 5d2e219 commit a032124

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

tests/AbstractLoopTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,6 @@ public function testSignalsKeepTheLoopRunningAndRemovingItStopsTheLoop()
589589
$this->assertRunFasterThan(1.6);
590590
}
591591

592-
public function testTimerIntervalBelowZeroRunsImmediately()
593-
{
594-
$this->loop->addTimer(-1, function () {});
595-
596-
$this->assertRunFasterThan(0.002);
597-
}
598-
599592
public function testTimerIntervalCanBeFarInFuture()
600593
{
601594
// Maximum interval for ExtUvLoop implementation

tests/Timer/AbstractTimerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,22 @@ public function testMinimumIntervalOneMicrosecond()
137137

138138
$this->assertEquals(0.000001, $timer->getInterval());
139139
}
140+
141+
public function testTimerIntervalBelowZeroRunsImmediately()
142+
{
143+
$loop = $this->createLoop();
144+
$start = 0;
145+
$loop->addTimer(
146+
-1,
147+
static function () use (&$start) {
148+
$start = \microtime(true);
149+
}
150+
);
151+
152+
$loop->run();
153+
$end = \microtime(true);
154+
155+
// 1ms should be enough even on slow machines
156+
$this->assertLessThan(0.001, $end - $start);
157+
}
140158
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy