public function FunctionsTest::testCanYieldErrorsAndSuccessesWithoutRecursion in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/promises/tests/functionsTest.php \GuzzleHttp\Promise\Tests\FunctionsTest::testCanYieldErrorsAndSuccessesWithoutRecursion()
File
- vendor/
guzzlehttp/ promises/ tests/ functionsTest.php, line 592
Class
Namespace
GuzzleHttp\Promise\TestsCode
public function testCanYieldErrorsAndSuccessesWithoutRecursion() {
$promises = [];
for ($i = 0; $i < 20; $i++) {
$promises[] = new P\Promise();
}
$co = P\coroutine(function () use ($promises) {
for ($i = 0; $i < 20; $i += 4) {
try {
(yield $promises[$i]);
(yield $promises[$i + 1]);
} catch (\Exception $e) {
(yield $promises[$i + 2]);
(yield $promises[$i + 3]);
}
}
});
for ($i = 0; $i < 20; $i += 4) {
$promises[$i]
->resolve($i);
$promises[$i + 1]
->reject($i + 1);
$promises[$i + 2]
->resolve($i + 2);
$promises[$i + 3]
->resolve($i + 3);
}
$co
->then(function ($value) use (&$result) {
$result = $value;
});
P\queue()
->run();
$this
->assertEquals('19', $result);
}