/** @dataProvider valueDataProvider */ public function testRaceGeneratorCreators($value, $otherValue = null) { $this->given($otherValue = $otherValue ?? $value, $creator = function ($limit, $value) { while ($limit-- > 0) { yield; } return (function () use($value) { yield; return $value; })(); })->then->object($generator = testedClass::race($creator(5, $value), $creator(3, $otherValue)))->isInstanceOf(\generator::class)->variable(testedClass::await($generator))->isIdenticalTo($otherValue); }
function race($first, $second, ...$generators) : \generator { return runtime::race($first, $second, ...$generators); }