10
@cython.test_fail_if_path_exists("//AddNode")
18
#@cython.test_fail_if_path_exists("//AddNode")
21
>>> add_var(10) == 1+2+10+3+4
26
@cython.test_fail_if_path_exists("//AddNode", "//SubNode")
29
>>> neg() == -1 -2 - (-3+4)
34
@cython.test_fail_if_path_exists("//AddNode", "//MulNode", "//DivNode")
37
>>> long_int_mix() == 1 + (2 * 3) // 2
39
>>> type(long_int_mix()) is int or type(long_int_mix())
42
return 1L + (2 * 3L) // 2
44
@cython.test_fail_if_path_exists("//AddNode", "//MulNode", "//DivNode")
47
>>> char_int_mix() == 1 + (ord(' ') * 3) // 2 + ord('A')
50
return 1L + (c' ' * 3L) // 2 + c'A'
52
@cython.test_fail_if_path_exists("//AddNode", "//MulNode")
55
>>> int_cast() == 1 + 2 * 6000
58
return <int>(1 + 2 * 6000)
60
@cython.test_fail_if_path_exists("//MulNode")
63
>>> mul() == 1*60*1000
68
@cython.test_fail_if_path_exists("//AddNode", "//MulNode")
71
>>> arithm() == 9*2+3*8//6-10
76
@cython.test_fail_if_path_exists("//AddNode", "//MulNode")
79
>>> parameters() == _func(-1 -2, - (-3+4), 1*2*3)
82
return _func(-1 -2, - (-3+4), 1*2*3)
84
#@cython.test_fail_if_path_exists("//AddNode")
87
>>> lists() == [1,2,3] + [4,5,6]
90
return [1,2,3] + [4,5,6]
92
@cython.test_fail_if_path_exists("//MulNode")
93
def multiplied_lists_right_len1():
95
>>> multiplied_lists_right_len1() == [1] * 5
100
@cython.test_fail_if_path_exists("//MulNode")
101
def multiplied_lists_right():
103
>>> multiplied_lists_right() == [1,2,3] * 5
108
@cython.test_fail_if_path_exists("//MulNode")
109
def multiplied_lists_left():
111
>>> multiplied_lists_left() == [1,2,3] * 5
116
@cython.test_fail_if_path_exists("//MulNode")
117
def multiplied_lists_neg():
119
>>> multiplied_lists_neg() == [1,2,3] * -5
124
@cython.test_fail_if_path_exists("//MulNode")
125
def multiplied_lists_nonconst(x):
127
>>> multiplied_lists_nonconst(5) == [1,2,3] * 5
129
>>> multiplied_lists_nonconst(-5) == [1,2,3] * -5
131
>>> multiplied_lists_nonconst(0) == [1,2,3] * 0
134
>>> try: [1,2,3] * 'abc'
135
... except TypeError: pass
136
>>> try: multiplied_nonconst_tuple_arg('abc')
137
... except TypeError: pass
138
>>> try: [1,2,3] * 1.0
139
... except TypeError: pass
140
>>> try: multiplied_nonconst_tuple_arg(1.0)
141
... except TypeError: pass
145
@cython.test_assert_path_exists("//MulNode")
146
def multiplied_lists_nonconst_left(x):
148
>>> multiplied_lists_nonconst_left(5) == 5 * [1,2,3]
150
>>> multiplied_lists_nonconst_left(-5) == -5 * [1,2,3]
152
>>> multiplied_lists_nonconst_left(0) == 0 * [1,2,3]
158
@cython.test_fail_if_path_exists("//MulNode")
159
def multiplied_nonconst_list_const_int(x):
161
>>> multiplied_nonconst_list_const_int(2)
167
@cython.test_fail_if_path_exists("//MulNode//ListNode")
168
def multiplied_lists_nonconst_expression(x):
170
>>> multiplied_lists_nonconst_expression(5) == [1,2,3] * (5 * 2)
172
>>> multiplied_lists_nonconst_expression(-5) == [1,2,3] * (-5 * 2)
174
>>> multiplied_lists_nonconst_expression(0) == [1,2,3] * (0 * 2)
177
return [1,2,3] * (x*2)
179
cdef side_effect(int x):
183
@cython.test_fail_if_path_exists("//MulNode")
184
def multiplied_lists_with_side_effects():
186
>>> multiplied_lists_with_side_effects() == [1,2,3] * 5
192
return [side_effect(1), side_effect(2), side_effect(3)] * 5
194
@cython.test_fail_if_path_exists("//MulNode")
195
def multiplied_lists_nonconst_with_side_effects(x):
197
>>> multiplied_lists_nonconst_with_side_effects(5) == [1,2,3] * 5
203
return [side_effect(1), side_effect(2), side_effect(3)] * x
205
@cython.test_fail_if_path_exists("//MulNode")
206
def multiplied_nonconst_tuple_arg(x):
208
>>> multiplied_nonconst_tuple_arg(5) == (1,2) * 5
210
>>> multiplied_nonconst_tuple_arg(-5) == (1,2) * -5
212
>>> multiplied_nonconst_tuple_arg(0) == (1,2) * 0
215
>>> try: (1,2) * 'abc'
216
... except TypeError: pass
217
>>> try: multiplied_nonconst_tuple_arg('abc')
218
... except TypeError: pass
220
... except TypeError: pass
221
>>> try: multiplied_nonconst_tuple_arg(1.0)
222
... except TypeError: pass
226
@cython.test_fail_if_path_exists("//MulNode")
227
def multiplied_nonconst_tuple_int_arg(int x):
229
>>> multiplied_nonconst_tuple_int_arg(5) == (1,2) * 5
234
@cython.test_fail_if_path_exists("//MulNode")
235
def multiplied_nonconst_tuple(x):
237
>>> multiplied_nonconst_tuple(5) == (1,2) * (5+1)
240
return (1,2) * (x + 1)
244
@cython.test_fail_if_path_exists("//MulNode")
245
def multiplied_global_nonconst_tuple():
247
>>> multiplied_global_nonconst_tuple() == (1,2,3) * 5
253
return (side_effect(1), side_effect(2), side_effect(3)) * MULT
255
@cython.test_fail_if_path_exists("//MulNode")
256
def multiplied_const_tuple():
258
>>> multiplied_const_tuple() == (1,2) * 5
263
@cython.test_fail_if_path_exists("//MulNode")
264
def multiplied_const_tuple_len1():
266
>>> multiplied_const_tuple_len1() == (1,) * 5
271
@cython.test_fail_if_path_exists("//PrimaryCmpNode")
272
def compile_time_DEF():
274
>>> compile_time_DEF()
275
(1, False, True, True, False)
277
return INT_VAL, INT_VAL == 0, INT_VAL != 0, INT_VAL == 1, INT_VAL != 1
279
@cython.test_fail_if_path_exists("//PrimaryCmpNode")
280
def cascaded_compare():
282
>>> cascaded_compare()