1313use Vector \Data \Result \Err ;
1414use Vector \Data \Result \Ok ;
1515use Vector \Data \Result \Result ;
16+ use Vector \Lib \Strings ;
1617use Vector \Test \Control \Stub \TestChildTypeA ;
1718use Vector \Test \Control \Stub \TestChildTypeB ;
1819use Vector \Test \Control \Stub \TestExtractableObject ;
@@ -93,7 +94,7 @@ public function it_can_match_on_default_case()
9394 public function it_can_match_on_maybe_nothing ()
9495 {
9596 $ match = Pattern::match ([
96- fn (Just $ value ) => $ value + 2 ,
97+ fn (Just $ value ) => $ value ,
9798 fn (Nothing $ _ ) => 'nothing ' ,
9899 ]);
99100
@@ -104,31 +105,31 @@ public function it_can_match_on_maybe_nothing()
104105 public function it_can_match_on_extractable ()
105106 {
106107 $ match = Pattern::match ([
107- fn (TestChildTypeA $ value ) => $ value + 1 ,
108- fn (TestChildTypeB $ value ) => $ value + 2 ,
108+ fn (TestChildTypeA $ value ) => Strings:: concat ( ' no ' ) ,
109+ fn (TestChildTypeB $ value ) => Strings:: concat ( ' bc ' ) ,
109110 ]);
110111
111- $ this ->assertEquals (3 , $ match (TestParentType::typeB (1 )));
112+ $ this ->assertEquals (' abc ' , $ match (TestParentType::typeB (' a ' )));
112113 }
113114
114115 /** @test */
115- public function it_can_auto_unwrap_a_wrapped_match ()
116+ public function it_can_auto_return_a_scalar_from_a_wrapped_match ()
116117 {
117118 $ match = Pattern::match ([
118119 fn (TestExtractableObject $ a ) => 'value ' ,
119120 ]);
120121
121- $ this ->assertEquals ('value ' , $ match (new TestExtractableObject (1 )));
122+ $ this ->assertEquals ('value ' , $ match (new TestExtractableObject (' a ' )));
122123 }
123124
124125 /** @test */
125126 public function it_auto_calls_a_matched_callable_value ()
126127 {
127128 $ match = Pattern::match ([
128- fn (TestExtractableObject $ a ) => fn ($ a ) => $ a + 1 ,
129+ fn (TestExtractableObject $ a ) => fn ($ a ) => $ a . ' bc ' ,
129130 ]);
130131
131- $ this ->assertEquals (2 , $ match (new TestExtractableObject (1 )));
132+ $ this ->assertEquals (' abc ' , $ match (new TestExtractableObject (' a ' )));
132133 }
133134
134135 /** @test */
0 commit comments