예제 #1
0
def test_option_some_bind_none_fluent():
    xs = Some(42)
    ys = xs.bind(lambda x: Nothing)

    for _ in ys.match(Nothing):
        assert True
        break
    else:
        assert False
예제 #2
0
def test_option_some_bind_fluent():
    xs = Some(42)
    ys = xs.bind(lambda x: Some(x + 1))

    for value in ys.match(Some):
        assert value == 43
        break
    else:
        assert False
예제 #3
0
def test_option_some_bind_fluent():
    xs = Some(42)
    ys = xs.bind(lambda x: Some(x + 1))

    assert ys.match(
        Some,
        lambda some: some.value == 43,
        _,
        False,
    )
예제 #4
0
def test_option_some_bind_none_fluent():
    xs = Some(42)
    ys = xs.bind(lambda x: Nothing)

    assert match(
        ys,
        Some,
        lambda some: False,
        _,
        True,
    )