cython

Форк
0
/
if_const.pyx 
195 строк · 4.1 Кб
1

2
cimport cython
3

4
DEF INT_VAL = 1
5

6
def _not_constant_but_False():
7
    return False
8

9
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
10
                                 "//IfStatNode")
11
def int_bool_result():
12
    """
13
    >>> int_bool_result()
14
    True
15
    """
16
    if 5:
17
        return True
18
    else:
19
        return False
20

21
@cython.test_fail_if_path_exists("//IfStatNode")
22
def constant_if_elif_else():
23
    """
24
    >>> constant_if_elif_else()
25
    True
26
    """
27
    if 0:
28
        return False
29
    elif 5:
30
        return True
31
    else:
32
        return False
33

34
@cython.test_fail_if_path_exists("//PrintStatNode")
35
@cython.test_assert_path_exists("//IfStatNode",
36
                                "//IfClauseNode")
37
def non_constant_if_elif_else1():
38
    """
39
    >>> non_constant_if_elif_else1()
40
    True
41
    """
42
    if _not_constant_but_False():
43
        return False
44
    elif 5:
45
        return True
46
    else:
47
        print(False)
48

49
@cython.test_fail_if_path_exists("//PrintStatNode")
50
@cython.test_assert_path_exists("//IfStatNode",
51
                                "//IfClauseNode")
52
def non_constant_if_elif_else2():
53
    """
54
    >>> non_constant_if_elif_else2()
55
    True
56
    """
57
    if _not_constant_but_False():
58
        return False
59
    elif 0:
60
        print(False)
61
    else:
62
        return True
63

64
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
65
                                 "//IfStatNode")
66
def if_not_compare_true():
67
    """
68
    >>> if_not_compare_true()
69
    False
70
    """
71
    if not 0 == 0:
72
        return True
73
    else:
74
        return False
75

76
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
77
                                 "//IfStatNode")
78
def if_compare_true():
79
    """
80
    >>> if_compare_true()
81
    True
82
    """
83
    if 0 == 0:
84
        return True
85
    else:
86
        return False
87

88
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
89
                                 "//IfStatNode")
90
def if_compare_false():
91
    """
92
    >>> if_compare_false()
93
    False
94
    """
95
    if 0 == 1:
96
        return True
97
    else:
98
        return False
99

100
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
101
                                 "//IfStatNode")
102
def if_compare_or_true():
103
    """
104
    >>> if_compare_or_true()
105
    True
106
    """
107
    if 0 == 1 or 1 == 1:
108
        return True
109
    else:
110
        return False
111

112
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
113
                                 "//IfStatNode")
114
def if_compare_or_false():
115
    """
116
    >>> if_compare_or_false()
117
    False
118
    """
119
    if 0 == 1 or 1 == 0:
120
        return True
121
    else:
122
        return False
123

124
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
125
                                 "//IfStatNode")
126
def if_compare_and_true():
127
    """
128
    >>> if_compare_and_true()
129
    True
130
    """
131
    if 0 == 0 and 1 == 1:
132
        return True
133
    else:
134
        return False
135

136
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
137
                                 "//IfStatNode")
138
def if_compare_and_false():
139
    """
140
    >>> if_compare_and_false()
141
    False
142
    """
143
    if 1 == 1 and 1 == 0:
144
        return True
145
    else:
146
        return False
147

148
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
149
                                 "//IfStatNode")
150
def if_compare_cascaded():
151
    """
152
    >>> if_compare_cascaded()
153
    True
154
    """
155
    if 0 < 1 < 2 < 3:
156
        return True
157
    else:
158
        return False
159

160
@cython.test_fail_if_path_exists("//CoerceToBooleanNode",
161
                                 "//ListNode",
162
                                 "//IfStatNode")
163
def list_bool_result_true():
164
    """
165
    >>> list_bool_result_true()
166
    True
167
    """
168
    if [1,2,3]:
169
        return True
170
    else:
171
        return False
172

173
@cython.test_fail_if_path_exists("//CoerceToBooleanNode",
174
                                 "//ListNode",
175
                                 "//IfStatNode")
176
def list_bool_result_false():
177
    """
178
    >>> list_bool_result_false()
179
    False
180
    """
181
    if []:
182
        return True
183
    else:
184
        return False
185

186
@cython.test_fail_if_path_exists("//PrimaryCmpNode",
187
                                 "//IfStatNode")
188
def compile_time_DEF_if():
189
    """
190
    >>> compile_time_DEF_if()
191
    True
192
    """
193
    if INT_VAL != 0:
194
        return True
195
    else:
196
        return False
197

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

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

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

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