You are here

private function FunctionsTest::createLotsOfFlappingPromise in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/promises/tests/functionsTest.php \GuzzleHttp\Promise\Tests\FunctionsTest::createLotsOfFlappingPromise()
2 calls to FunctionsTest::createLotsOfFlappingPromise()
FunctionsTest::testLotsOfTryCatchingDoesNotBlowStack in vendor/guzzlehttp/promises/tests/functionsTest.php
FunctionsTest::testLotsOfTryCatchingWaitingDoesNotBlowStack in vendor/guzzlehttp/promises/tests/functionsTest.php

File

vendor/guzzlehttp/promises/tests/functionsTest.php, line 467

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

private function createLotsOfFlappingPromise() {
  return P\coroutine(function () {
    $value = 0;
    for ($i = 0; $i < 1000; $i++) {
      try {
        if ($i % 2) {
          $value = (yield new P\FulfilledPromise($i));
        }
        else {
          $value = (yield new P\RejectedPromise($i));
        }
      } catch (\Exception $e) {
        $value = (yield new P\FulfilledPromise($i));
      }
    }
    (yield $value);
  });
}