cython

Форк
0
/
bint_binop_T145.pyx 
135 строк · 2.3 Кб
1
# ticket: t145
2

3
cimport cython
4

5
@cython.test_fail_if_path_exists('//BoolBinopNode')
6
def or_literal_bint():
7
    """
8
    >>> True or 5
9
    True
10
    >>> or_literal_bint()
11
    True
12
    """
13
    return True or 5
14

15
@cython.test_fail_if_path_exists('//BoolBinopNode')
16
def and_literal_bint():
17
    """
18
    >>> 5 and True
19
    True
20
    >>> and_literal_bint()
21
    True
22
    """
23
    return 5 and True
24

25
@cython.test_fail_if_path_exists('//BoolBinopNode')
26
def False_and_True_or_0():
27
    """
28
    >>> False and True or 0
29
    0
30
    >>> False_and_True_or_0()
31
    0
32
    """
33
    return False and True or 0
34

35
@cython.test_fail_if_path_exists('//BoolBinopNode')
36
def True_and_True_or_0():
37
    """
38
    >>> True and True or 0
39
    True
40
    >>> True_and_True_or_0()
41
    True
42
    """
43
    return True and True or 0
44

45
def x_and_True_or_False(x):
46
    """
47
    >>> x_and_True_or_False(0)
48
    False
49
    >>> x_and_True_or_False(1)
50
    True
51
    >>> x_and_True_or_False('abc')
52
    True
53
    >>> x_and_True_or_False([])
54
    False
55
    """
56
    return x and True or False
57

58
def x_and_True_or_0(x):
59
    """
60
    >>> 0 and True or 0
61
    0
62
    >>> x_and_True_or_0(0)
63
    0
64

65
    >>> 1 and True or 0
66
    True
67
    >>> x_and_True_or_0(1)
68
    True
69

70
    >>> x_and_True_or_0('abc')
71
    True
72
    >>> x_and_True_or_0([])
73
    0
74
    """
75
    return x and True or 0
76

77
def x_and_True_or_1(x):
78
    """
79
    >>> 0 and True or 1
80
    1
81
    >>> x_and_True_or_1(0)
82
    1
83

84
    >>> 1 and True or 1
85
    True
86
    >>> x_and_True_or_1(1)
87
    True
88

89
    >>> x_and_True_or_1('abc')
90
    True
91
    >>> x_and_True_or_1([])
92
    1
93
    """
94
    return x and True or 1
95

96
def x_and_1_or_False(x):
97
    """
98
    >>> 0 and 1 or False
99
    False
100
    >>> x_and_1_or_False(0)
101
    False
102

103
    >>> 1 and 1 or False
104
    1
105
    >>> x_and_1_or_False(1)
106
    1
107

108
    >>> x_and_1_or_False('abc')
109
    1
110
    >>> x_and_1_or_False([])
111
    False
112
    """
113
    return x and 1 or False
114

115
def test_large_int(unsigned long x):
116
    """
117
    >>> try: test_large_int(1 << 127)
118
    ... except OverflowError: print(True)
119
    True
120
    >>> try: test_large_int(1 << 63)
121
    ... except OverflowError: print(True)
122
    True
123
    >>> try: test_large_int(1 << 48)
124
    ... except OverflowError: print(True)
125
    True
126
    >>> try: test_large_int(1 << 31)
127
    ... except OverflowError: print(True)
128
    True
129
    >>> test_large_int(0)
130
    False
131
    """
132
    if True and x:
133
        return True
134
    else:
135
        return False
136

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.