Skip to content

Commit

Permalink
Added early return tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielSanchezQ committed Mar 28, 2024
1 parent 8fbeefc commit 36c024b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rusty_results/tests/option/test_option_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ def test_transpose():
this: Empty = Empty()
assert this.transpose() == Ok(Empty())


def test_early_return():
with pytest.raises(EarlyReturnException):
this: Empty = Empty()
_ = ~this
5 changes: 5 additions & 0 deletions rusty_results/tests/option/test_option_some.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,8 @@ def test_transpose(option, expected_transpose):
def test_transpose_type_error():
with pytest.raises(TypeError):
Some(10).transpose()


def test_early_return():
value = ~Some(10)
assert value == 10
6 changes: 6 additions & 0 deletions rusty_results/tests/result/test_result_err.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,9 @@ def test_flatten():
def test_transpose():
this: Result = Err(None)
assert this.transpose() == Some(Err(None))


def test_early_return():
err: Result[int, int] = Err(0)
with pytest.raises(EarlyReturnException):
_ = ~err
5 changes: 5 additions & 0 deletions rusty_results/tests/result/test_result_ok.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ def test_transpose(result, expected_transpose):
def test_transpose_type_error():
with pytest.raises(TypeError):
Ok(10).transpose()


def test_early_return():
err: Result[int, int] = Ok(0)
assert ~err == 0

0 comments on commit 36c024b

Please sign in to comment.