Example #1
0
def test_option_some_map2_piped(x: int, y: int):
    xs = Some(x)
    ys = Some(y)
    mapper: Callable[[int, int], int] = lambda x, y: x + y
    zs = pipe2((xs, ys), option.map2(mapper))

    for value in zs.match(Some):
        assert value == x + y
        break
    else:
        assert False
Example #2
0
def test_pipe2_fn_gn(x: int, y: int):
    gn: Callable[[int], int] = lambda g: g * y
    fn: Callable[[int, int], int] = lambda x, y: x + y
    value = pipe2((x, y), fn, gn)

    assert value == gn(fn(x, y))
Example #3
0
def test_pipe2_fn(x: int, y: int):
    value = pipe2((x, y), lambda x, y: x + y)
    assert value == x + y
Example #4
0
def test_pipe2_id(x: int, y: int):
    value = pipe2((x, y))
    assert value == (x, y)
Example #5
0
def test_option_some_map2_piped(x: int, y: int):
    xs = Some(x)
    ys = Some(y)
    zs = pipe2((xs, ys), option.map2(lambda x, y: x + y))

    assert zs.match(Some, lambda some: some.value, _, False) == x + y