File: or.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (75 lines) | stat: -rw-r--r-- 1,332 bytes parent folder | download | duplicates (5)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
a,b = 'a *','b *' # use non-interned strings

def or2_assign(a,b):
    """
    >>> or2_assign(2,3) == (2 or 3)
    True
    >>> or2_assign('a', 'b') == ('a' or 'b')
    True
    >>> or2_assign(a, b) == (a or b)
    True
    """
    c = a or b
    return c

def or2(a,b):
    """
    >>> or2(2,3) == (2 or 3)
    True
    >>> or2(0,2) == (0 or 2)
    True
    >>> or2('a', 'b') == ('a' or 'b')
    True
    >>> or2(a, b) == (a or b)
    True
    >>> or2('', 'b') == ('' or 'b')
    True
    >>> or2([], [1]) == ([] or [1])
    True
    >>> or2([], [a]) == ([] or [a])
    True
    """
    return a or b

def or3(a,b,c):
    """
    >>> or3(0,1,2) == (0 or 1 or 2)
    True
    >>> or3([],(),[1]) == ([] or () or [1])
    True
    """
    d = a or b or c
    return d

def or2_no_result(a,b):
    """
    >>> or2_no_result(2,3)
    >>> or2_no_result(0,2)
    >>> or2_no_result('a','b')
    >>> or2_no_result(a,b)
    >>> a or b
    'a *'
    """
    a or b

def or2_literal():
    """
    >>> or2_literal()
    5
    """
    return False or 5

cdef class A(object):
    def __repr__(self):
        return "A"

def test_GH2059_missing_cast():
    """
    >>> test_GH2059_missing_cast()
    (A, A)
    """
    cdef A a = A()
    cdef object o = None
    cdef A a_first = a or o
    cdef A a_second = o or a
    return a_first, a_second