-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReturnOnlyTest.php
More file actions
40 lines (27 loc) · 872 Bytes
/
ReturnOnlyTest.php
File metadata and controls
40 lines (27 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php declare(strict_types=1);
namespace Versary\EffectSystem;
use PHPUnit\Framework\TestCase;
use Versary\EffectSystem\Errors\UnhandledEffect;
use Versary\EffectSystem\Tests\ReturnOnlyTest\ReturnOnlyHandler;
class ReturnOnlyTest extends TestCase
{
function program() {
// force this function to be a generator
false && yield false;
return 3;
}
public function test_return_only() {
$gen = $this->program();
$gen = Effect::handle($gen, new ReturnOnlyHandler);
$result = Effect::run($gen);
$this->assertEquals(6, $result);
}
}
namespace Versary\EffectSystem\Tests\ReturnOnlyTest;
use Versary\EffectSystem\{Effect, Handler};
class ReturnOnlyHandler extends Handler {
public static $effect = stdClass::class;
public function return(mixed $value) {
return $value * 2;
}
}