8000 Move "testTimerIntervalBelowZeroRunsImmediately" from AbstractLoopTes… · reactphp/event-loop@a032124 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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)
0