Exemple #1
0
def test_reduce_nil():
    # pylint: disable=missing-docstring
    initial = 1232
    slst = SList()
    res = slst.reduce(operator.add, initial)
    exp = initial
    assert res == exp
Exemple #2
0
def test_reduce_sum_non_empty():
    # pylint: disable=missing-docstring
    slst = SList([1, 2, 3, 4, 5, 6])
    exp = 22
    res = slst.reduce(operator.add, 1)
    assert res == exp
Exemple #3
0
def test_reduce_sum_empty():
    # pylint: disable=missing-docstring
    slst = SList()
    exp = 0
    res = slst.reduce(operator.add, 0)
    assert res == exp
Exemple #4
0
def test_reduce_cons():
    # pylint: disable=missing-docstring
    slst = SList([1, 2, 3, 4])
    res = slst.reduce(operator.add)
    exp = 10
    assert res == exp