-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(bind): add implementation * feat(bind): improve doc example * fix: some errors with testing modules
- Loading branch information
1 parent
d7c7dd0
commit d702314
Showing
7 changed files
with
107 additions
and
12 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
Empty file.
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,41 @@ | ||
import pytest | ||
|
||
from meiga import Failure, Success | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_bind_a_success_result_encapsulated_value(): | ||
result = Success("hi") | ||
|
||
def func(value: str): | ||
return value.capitalize() | ||
|
||
result.bind(func) | ||
|
||
assert result.value == "Hi" | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_bind_several_times_success_result(): | ||
result = Success(0) | ||
|
||
def func(value: int): | ||
return value + 1 | ||
|
||
result.bind(func).bind(func).bind(func).bind(func).bind(func).bind(func).bind( | ||
func | ||
).bind(func).bind(func).bind(func) | ||
|
||
assert result.value == 10 | ||
|
||
|
||
@pytest.mark.unit | ||
def test_should_bind_and_keep_same_object_when_failure(): | ||
result = Failure("failure_value") | ||
|
||
def func(value: str): | ||
return value.capitalize() | ||
|
||
result.bind(func) | ||
|
||
assert result.value == "failure_value" |
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