Skip to content

Commit

Permalink
Fix missing return value of Coroutine\go
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jun 25, 2021
1 parent 4287a48 commit 1ed49db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/Coroutine/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function run(callable $fn, ...$args)

function go(callable $fn, ...$args)
{
Coroutine::create($fn, ...$args);
return Coroutine::create($fn, ...$args);
}

function defer(callable $fn)
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/Coroutine/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function testBatch()
});
}

public function testGo()
{
run(function () {
$cid = go(function() {
System::sleep(0.001);
});
$this->assertTrue(is_int($cid) and $cid > 0);
});
}

public function testParallel()
{
run(function () {
Expand Down

0 comments on commit 1ed49db

Please sign in to comment.