1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/test/DelayedTest.php
2020-10-10 09:06:49 -05:00

37 lines
663 B
PHP

<?php
namespace Amp\Test;
use Amp\Delayed;
use Amp\PHPUnit\AsyncTestCase;
use function Amp\await;
class DelayedTest extends AsyncTestCase
{
public function testDelayed(): void
{
$this->setMinimumRuntime(100);
$time = 100;
$value = "test";
$promise = new Delayed($time, $value);
$this->assertSame($value, await($promise));
}
public function testReference(): void
{
$this->setMinimumRuntime(100);
$time = 100;
$value = "test";
$promise = new Delayed($time, $value);
$promise->unreference();
$promise->reference();
await($promise);
}
}