def test_empty_match(if_some: Callable[[object], _U], if_empty: Callable[[], _U], exp: _U) -> None: assert Empty().match(if_some=if_some, if_empty=if_empty) == exp
def test_empty_map(_: object, fn: Callable[[object], object]) -> None: assert Empty().map(fn) == Empty()
def test_empty_flat_map(_v: object, fn: Callable[[object], Maybe[_U]], _exp: object) -> None: assert Empty().flat_map(fn) == Empty()
def test_empty_unwrap_raises_error() -> None: with pytest.raises(ValueError): Empty().unwrap()
def test_empty_is_hashable() -> None: {Empty()}
def test_some_and_empty_are_not_equal(v: object) -> None: assert Some(v) != Empty() and Empty() != Some(v)
def test_empty_eq_is_reflexive_and_symmetric() -> None: assert Empty() == Empty()
# todo more test cases ] @pytest.mark.parametrize('v, fn', _MAP_TEST_CASES) def test_some_map(v: _T, fn: Callable[[_T], object]) -> None: assert Some(v).map(fn) == Some(fn(v)) @pytest.mark.parametrize('_, fn', _MAP_TEST_CASES) def test_empty_map(_: object, fn: Callable[[object], object]) -> None: assert Empty().map(fn) == Empty() _FLATMAP_TEST_CASES: Final = [(1, lambda x: Some(x + 1), Some(2)), (1, lambda x: Empty(), Empty()) # todo more test cases ] @pytest.mark.parametrize('v, fn, exp', _FLATMAP_TEST_CASES) def test_some_flat_map(v: _T, fn: Callable[[_T], Maybe[_U]], exp: Maybe[_U]) -> None: assert Some(v).flat_map(fn) == exp @pytest.mark.parametrize('_v, fn, _exp', _FLATMAP_TEST_CASES) def test_empty_flat_map(_v: object, fn: Callable[[object], Maybe[_U]], _exp: object) -> None: assert Empty().flat_map(fn) == Empty()