27 $this->assertEquals(1,
$start);
46 $this->assertEquals(3,
$start);
64 }
catch (\Exception $e) {
65 $start += $e->getMessage();
71 $this->assertEquals(3,
$start);
79 $reject(
new \LogicException(
'2'));
89 }
catch (\LogicException $e) {
90 $start += $e->getMessage();
96 $this->assertEquals(3,
$start);
114 }
catch (\Exception $e) {
115 $this->assertTrue(strpos($e->getMessage(),
'Promise was rejected with') === 0);
121 $this->assertEquals(3,
$start);
137 $this->assertEquals(1,
$start);
142 $this->assertEquals(3,
$start);
157 }
catch (\Exception $e) {
158 $start += $e->getMessage();
163 $this->assertEquals(1,
$start);
165 $promise->reject(
new \Exception(2));
168 $this->assertEquals(3,
$start);
180 throw new \Exception(
'4');
184 $start += $e->getMessage();
189 $this->assertEquals(7,
$start);
204 $start += $e->getMessage();
208 $this->assertEquals(1,
$start);
210 $promise->reject(
new \Exception(2));
213 $this->assertEquals(3,
$start);
226 })->then(
function($value) use (&
$ok) {
227 $this->assertEquals(2, $value);
229 })->
error(
function($reason) {
230 $this->fail($reason);
234 $this->assertTrue(
$ok);
250 })->then(
function($value) use (&
$ok) {
252 $this->fail($reason);
258 $this->assertEquals(
'omg it worked',
$ok);
An exception for terminatinating execution or to throw for unit testing.
testNonGenerator()
@expectedException \InvalidArgumentException
testRejectedPromiseAsync()
testFulfilledPromiseAsync()
testRejectedPromiseException()
testRejectedPromiseArray()
testResolveToLastYieldPromise()
An implementation of the Promise pattern.
error($a_errmsg)
set error message @access public
coroutine(callable $gen)
Turn asynchronous promise-based code into something that looks synchronous again, through the use of ...
$promise
This example shows demonstrates the Promise api.