-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Innmind/reduce-circular-dependencies
Reduce circular dependencies
- Loading branch information
Showing
9 changed files
with
292 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
use Innmind\Immutable\Maybe; | ||
use Innmind\BlackBox\Set; | ||
|
||
return static function() { | ||
yield proof( | ||
'Maybe::defer() holds intermediary values', | ||
given( | ||
Set\Type::any(), | ||
Set\Type::any(), | ||
), | ||
static function($assert, $value1, $value2) { | ||
$m1 = Maybe::defer(static function() use ($value1) { | ||
static $loaded = false; | ||
|
||
if ($loaded) { | ||
throw new Exception; | ||
} | ||
|
||
$loaded = true; | ||
|
||
return Maybe::just($value1); | ||
}); | ||
$m2 = $m1->map(static fn() => $value2); | ||
|
||
$assert->same( | ||
$value2, | ||
$m2->match( | ||
static fn($value) => $value, | ||
static fn() => null, | ||
), | ||
); | ||
$assert->not()->throws( | ||
static fn() => $assert->same( | ||
$value1, | ||
$m1->match( | ||
static fn($value) => $value, | ||
static fn() => null, | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.