Skip to content

Commit 302a568

Browse files
committed
Update it_can_match_on_extractable to use Strings::concat.
1 parent 8c4d37c commit 302a568

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

tests/Control/PatternTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Vector\Data\Result\Err;
1414
use Vector\Data\Result\Ok;
1515
use Vector\Data\Result\Result;
16+
use Vector\Lib\Strings;
1617
use Vector\Test\Control\Stub\TestChildTypeA;
1718
use Vector\Test\Control\Stub\TestChildTypeB;
1819
use 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

Comments
 (0)