File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 10
10
use Psl \Comparison \Order ;
11
11
use Psl \Option ;
12
12
use Psl \Option \Exception \NoneException ;
13
+ use Psl \Ref ;
13
14
14
15
final class NoneTest extends TestCase
15
16
{
@@ -86,14 +87,15 @@ public function testContains(): void
86
87
87
88
public function testApply (): void
88
89
{
89
- $ i = 1 ;
90
+ $ spy = new Ref ( 1 ) ;
90
91
91
92
$ option = Option \none ();
92
- $ option ->apply (static function (int $ value ) use (& $ i ) {
93
- $ i += $ value ;
93
+ $ option ->apply (static function (int $ value ) use ($ spy ) {
94
+ $ spy -> value += $ value ;
94
95
});
95
96
96
- static ::assertSame (1 , $ i );
97
+ static ::assertSame (1 , $ spy ->value );
98
+ static ::assertTrue ($ option ->isNone ());
97
99
}
98
100
99
101
public function testMap (): void
Original file line number Diff line number Diff line change 9
9
use Psl \Comparison \Equable ;
10
10
use Psl \Comparison \Order ;
11
11
use Psl \Option ;
12
+ use Psl \Ref ;
12
13
use Psl \Tests \Fixture ;
13
14
use Psl \Type ;
14
15
@@ -85,14 +86,15 @@ public function testContains(): void
85
86
86
87
public function testApply (): void
87
88
{
88
- $ i = 1 ;
89
+ $ spy = new Ref ( 1 ) ;
89
90
90
91
$ option = Option \some (2 );
91
- $ option ->apply (static function (int $ value ) use (& $ i ) {
92
- $ i += $ value ;
92
+ $ option ->apply (static function (int $ value ) use ($ spy ) {
93
+ $ spy -> value += $ value ;
93
94
});
94
95
95
- static ::assertSame (3 , $ i );
96
+ static ::assertSame (3 , $ spy ->value );
97
+ static ::assertSame (2 , $ option ->unwrap ());
96
98
}
97
99
98
100
public function testMap (): void
You can’t perform that action at this time.
0 commit comments