Exemple #1
0
def test_append():
    assert ImmutableList.of(1, 2).append(3) == ImmutableList.of(1, 2, 3)
Exemple #2
0
def test_find_negative():
    assert ImmutableList.of(1, 2, 3, 4).find(lambda item: item < 0) is None
Exemple #3
0
def test_unshift():
    assert ImmutableList.of(1, 2).unshift(0) == ImmutableList.of(0, 1, 2)
Exemple #4
0
def test_plus_operator_exception():
    with pytest.raises(ValueError):
        ImmutableList.of(0) + [1]
Exemple #5
0
def test_find_positive():
    assert ImmutableList.of(1, 2, 3, 4).find(lambda item: item % 2 == 0) == 2
Exemple #6
0
def test_plus_operator():
    assert ImmutableList.of(1, 2) + ImmutableList.of(3, 4) == ImmutableList.of(
        1, 2, 3, 4)
Exemple #7
0
def test_empty_filter():
    assert ImmutableList.of(
        1, 2, 3, 4).filter(lambda item: False) == ImmutableList.empty()
Exemple #8
0
def test_filter():
    assert ImmutableList.of(
        1, 2, 3,
        4).filter(lambda item: item % 2 == 0) == ImmutableList.of(2, 4)
Exemple #9
0
def test_map():
    assert ImmutableList.of(1, 2, 3,
                            4).map(lambda item: item + 1) == ImmutableList.of(
                                2, 3, 4, 5)
Exemple #10
0
def test_of():
    assert ImmutableList.of(1, 2, 3, 4).to_list() == [1, 2, 3, 4]