1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 00:49:48 +01:00
amp/test/Loop/UvLoopDestructShutdown.phpt
Aaron Piotrowski 45bd189e76
Add Driver::clear()
Intended for tests over swapping the entire event loop.

This allows forbidding swapping the global event loop once it is started.
2020-10-03 08:38:31 -05:00

38 lines
712 B
PHP

--TEST--
Test order of destruction not interfering with access to UV handles
--SKIPIF--
<?php
\extension_loaded("uv") or die("SKIP: ext/uv required for this test");
?>
--FILE--
<?php
include __DIR__.'/../../vendor/autoload.php';
use Amp\Loop\UvDriver;
$loop = new UvDriver;
$loop->setState('test', new class($loop) {
private UvDriver $loop;
private string $handle;
public function __construct(UvDriver $loop)
{
$this->loop = $loop;
$this->handle = $this->loop->repeat(10, function () {});
}
public function __destruct()
{
$this->loop->cancel($this->handle);
print "ok";
}
});
$loop->delay(0, [$loop, "stop"]);
$loop->run();
?>
--EXPECT--
ok