补充测试用例

This commit is contained in:
reasno 2019-11-10 00:26:46 +08:00
parent 572ba68f83
commit 242e7b81c0

View File

@ -115,6 +115,28 @@ class ParallelTest extends TestCase
$this->assertEquals(count($res), 4);
}
public function testParallelThrows()
{
$parallel = new Parallel();
$err = function () {
Coroutine::sleep(0.001);
throw new \RuntimeException();
};
$ok = function () {
Coroutine::sleep(0.001);
return 1;
};
$parallel->add($err);
for ($i = 0; $i < 4; ++$i) {
$parallel->add($ok);
}
$this->expectException(\RuntimeException::class);
$res = $parallel->wait();
}
public function returnCoId()
{
return Coroutine::id();