1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00

Add failing Coroutine test

This commit is contained in:
Niklas Keller 2019-03-14 22:31:27 +01:00 committed by Aaron Piotrowski
parent a660af794b
commit aeb5de16d9

View File

@ -13,6 +13,7 @@ use Amp\Success;
use PHPUnit\Framework\TestCase;
use React\Promise\FulfilledPromise as FulfilledReactPromise;
use React\Promise\Promise as ReactPromise;
use function Amp\call;
class CoroutineTest extends TestCase
{
@ -476,6 +477,37 @@ class CoroutineTest extends TestCase
$this->assertSame($exception, $reason);
}
/**
* @depends testGeneratorThrowingExceptionWithFinallyFailsCoroutine
*/
public function testGeneratorThrowingExceptionWithFinallyBlockAndReturnThrowing()
{
$exception = new \Exception;
$generator = function () use ($exception) {
yield new Success;
return call(function () use ($exception) {
return new class($exception)
{
private $exception;
public function __construct(\Throwable $exception)
{
$this->exception = $exception;
}
public function __destruct()
{
throw $this->exception;
}
};
});
};
new Coroutine($generator());
}
/**
* @depends testYieldSuccessfulPromise
*/