Add missing result test

This commit is contained in:
Correl Roush 2018-12-12 01:17:49 -05:00
parent 90b2ec49ef
commit 7608fa40fe
2 changed files with 7 additions and 2 deletions

View file

@ -18,7 +18,7 @@ class Monad(Applicative[T]):
raise NotImplementedError
@classmethod
def pure(cls, value: T) -> Monad[T]:
def pure(cls, value: T) -> Monad[T]: # pragma: no cover
raise NotImplementedError
@classmethod

View file

@ -63,11 +63,16 @@ def test_map_infix() -> None:
assert "5" == mapped.withDefault("0")
def test_map_error() -> None:
def test_map_error_err() -> None:
m: Result[int, str] = Err("oops")
assert Err(4) == m.mapError(len)
def test_map_error_ok() -> None:
m: Result[int, str] = Ok(123)
assert Ok(123) == m.mapError(len)
def test_bind() -> None:
result: Result[int, str] = Ok(5)
incremented: Result[int, str] = result.bind(lambda x: Ok(x + 1))