コード例 #1
0
ファイル: test_option.py プロジェクト: exyi/Expression
def test_option_some_map_piped():
    xs = Some(42)
    ys: Option[int] = xs.pipe(option.map(lambda x: x + 1))

    for y in ys:
        assert y == 43
        break
    else:
        assert False
コード例 #2
0
def test_option_some_map_piped():
    xs = Some(42)
    mapper: Callable[[int], int] = lambda x: x + 1
    ys: Option[int] = xs.pipe(option.map(mapper))

    for y in ys.match(Some):
        assert y == 43
        break
    else:
        assert False
コード例 #3
0
def test_option_some_bind_piped():
    binder: Callable[[int], Option[int]] = lambda x: Some(x + 1)
    xs = Some(42)
    ys = xs.pipe(option.bind(binder), )

    for value in ys.match(Some):
        assert value == 43
        break
    else:
        assert False
コード例 #4
0
ファイル: test_option.py プロジェクト: exyi/Expression
def test_option_some_bind_piped():
    xs = Some(42)
    ys = xs.pipe(option.bind(lambda x: Some(x + 1)), )

    assert ys.match(
        Some,
        lambda some: some.value == 43,
        _,
        False,
    )