Skip to content

Commit 16e4511

Browse files
authored
Merge pull request #23 from clue-labs/cap
Cap minimum timer interval at 1µs across all versions
2 parents ddedc67 + 8c741fd commit 16e4511

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require": {
2121
"php": ">=5.3",
22-
"react/event-loop": "~0.4.0|~0.3.0",
22+
"react/event-loop": "^0.4 || ^0.3.5",
2323
"react/promise": "~2.1|~1.2"
2424
}
2525
}

tests/FunctionRejectTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function testPromiseIsPendingWithoutRunningLoop()
1313
$this->expectPromisePending($promise);
1414
}
1515

16+
public function testPromiseExpiredIsPendingWithoutRunningLoop()
17+
{
18+
$promise = Timer\reject(-1, $this->loop);
19+
20+
$this->expectPromisePending($promise);
21+
}
22+
1623
public function testPromiseWillBeRejectedOnTimeout()
1724
{
1825
$promise = Timer\reject(0.01, $this->loop);
@@ -22,6 +29,15 @@ public function testPromiseWillBeRejectedOnTimeout()
2229
$this->expectPromiseRejected($promise);
2330
}
2431

32+
public function testPromiseExpiredWillBeRejectedOnTimeout()
33+
{
34+
$promise = Timer\reject(-1, $this->loop);
35+
36+
$this->loop->run();
37+
38+
$this->expectPromiseRejected($promise);
39+
}
40+
2541
public function testCancelingPromiseWillRejectTimer()
2642
{
2743
$promise = Timer\reject(0.01, $this->loop);

tests/FunctionResolveTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function testPromiseIsPendingWithoutRunningLoop()
1313
$this->expectPromisePending($promise);
1414
}
1515

16+
public function testPromiseExpiredIsPendingWithoutRunningLoop()
17+
{
18+
$promise = Timer\resolve(-1, $this->loop);
19+
20+
$this->expectPromisePending($promise);
21+
}
22+
1623
public function testPromiseWillBeResolvedOnTimeout()
1724
{
1825
$promise = Timer\resolve(0.01, $this->loop);
@@ -22,6 +29,15 @@ public function testPromiseWillBeResolvedOnTimeout()
2229
$this->expectPromiseResolved($promise);
2330
}
2431

32+
public function testPromiseExpiredWillBeResolvedOnTimeout()
33+
{
34+
$promise = Timer\resolve(-1, $this->loop);
35+
36+
$this->loop->run();
37+
38+
$this->expectPromiseResolved($promise);
39+
}
40+
2541
public function testWillStartLoopTimer()
2642
{
2743
$loop = $this->getMock('React\EventLoop\LoopInterface');

tests/FunctionTimeoutTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ public function testResolvedWillResolveRightAway()
1616
$this->expectPromiseResolved($promise);
1717
}
1818

19+
public function testResolvedExpiredWillResolveRightAway()
20+
{
21+
$promise = Promise\resolve();
22+
23+
$promise = Timer\timeout($promise, -1, $this->loop);
24+
25+
$this->expectPromiseResolved($promise);
26+
}
27+
1928
public function testResolvedWillNotStartTimer()
2029
{
2130
$promise = Promise\resolve();

0 commit comments

Comments
 (0)