summaryrefslogtreecommitdiff
path: root/tests/run/in_list_with_side_effects_T544.pyx
blob: 3bb3954c38831e18533b996ca29c565847944b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# ticket: 544

def count(i=[0]):
    i[0] += 1
    return i[0]

def test(x):
    """
    >>> def py_count(i=[0]):
    ...     i[0] += 1
    ...     return i[0]
    >>> 1 in (py_count(), py_count(), py_count(), py_count())
    True
    >>> 4 in (py_count(), py_count(), py_count(), py_count())
    False
    >>> 12 in (py_count(), py_count(), py_count(), py_count())
    True

    >>> test(1)
    True
    >>> test(4)
    False
    >>> test(12)
    True
    """
    return x in (count(), count(), count(), count())