mirror of
https://github.com/danog/amp.git
synced 2024-12-02 17:37:50 +01:00
28 lines
574 B
PHP
28 lines
574 B
PHP
<?php
|
|
|
|
namespace Amp\Test;
|
|
|
|
use Amp\Loop;
|
|
use Amp\PHPUnit\AsyncTestCase;
|
|
use Amp\PHPUnit\TestException;
|
|
use function Amp\defer;
|
|
use function Amp\delay;
|
|
|
|
class DeferTest extends AsyncTestCase
|
|
{
|
|
public function testExceptionsRethrownToLoopHandler(): void
|
|
{
|
|
Loop::setErrorHandler(function (\Throwable $exception) use (&$reason): void {
|
|
$reason = $exception;
|
|
});
|
|
|
|
$exception = new TestException;
|
|
|
|
defer(fn() => throw $exception);
|
|
|
|
delay(5); // Tick event loop.
|
|
|
|
$this->assertSame($exception, $reason);
|
|
}
|
|
}
|