8
@cython.test_fail_if_path_exists(
15
(False, 2.0, -2.0, False, 2.0, -2.0, -2.0)
20
not3 = not not not 2.0
24
return not1, plus1, minus1, not3, plus3, minus3, mix
27
@cython.test_fail_if_path_exists(
30
"//CoerceToPyTypeNode",
32
def unop_py_floats_tuple():
35
(False, 2.0, -2.0, False, 2.0, -2.0, -2.0)
47
@cython.test_fail_if_path_exists(
54
(False, 2, -2, False, 2, -2, -2)
63
return not1, plus1, minus1, not3, plus3, minus3, mix
66
@cython.test_fail_if_path_exists(
74
(False, 1, -1, False, 1, -1, -1)
79
not3 = not not not True
83
return not1, plus1, minus1, not3, plus3, minus3, mix
86
@cython.test_fail_if_path_exists(
93
(2, 1, 0, True, True, 1, False, 2, 2, -2, False, True, 1, False)
102
plus3 = False + True + False + True
103
pmix3 = False + True + 0 + True
104
minus3 = False - True - False - True
105
and3 = False & True & False & True
106
or3 = False | True | False | True
107
ormix3 = False | 0 | False | True
108
xor3 = False ^ True ^ False ^ True
109
return plus1, pmix1, minus1, and1, or1, ormix1, xor1, plus3, pmix3, minus3, and3, or3, ormix3, xor3
112
@cython.test_fail_if_path_exists(
119
(800, 12193263111263526900, 248832, 12467572902176589255564000298710470656)
122
mul_large_int = 1234567890 * 9876543210
124
pow_large_int = 1234 ** 12
125
return (mul_int, mul_large_int, pow_int, pow_large_int)
128
def binop_pow_negative():
130
>>> binop_pow_negative()
131
(4.018775720164609e-06, 8.020807320287816e-38, 0.1)
134
pow_large_int = 1234 ** -12
135
pow_expression_int = 10 ** (1-2)
136
return (pow_int, pow_large_int, pow_expression_int)
139
@cython.test_fail_if_path_exists(
145
([1, 2, 3, 4], [3, 4], [1, 2, 3, 4], [3, 4], (1, 2, 3, 4), (3, 4), (1, 2, 3, 4), (3, 4))
147
lst0 = [1, 2, 3, 4][:]
148
lst1 = [1, 2, 3, 4][2:]
149
lst2 = [1, 2, 3, 4][:4]
150
lst3 = [1, 2, 3, 4][2:4]
152
tpl0 = (1, 2, 3, 4)[:]
153
tpl1 = (1, 2, 3, 4)[2:]
154
tpl2 = (1, 2, 3, 4)[:4]
155
tpl3 = (1, 2, 3, 4)[2:4]
157
return lst0, lst1, lst2, lst3, tpl0, tpl1, tpl2, tpl3
160
@cython.test_fail_if_path_exists(
165
>>> a,b,c,d = str_slicing2()
166
>>> a == 'abc\\xE9def'[:]
168
>>> b == 'abc\\xE9def'[2:]
170
>>> c == 'abc\\xE9def'[:4]
172
>>> d == 'abc\\xE9def'[2:4]
175
str0 = 'abc\xE9def'[:]
176
str1 = 'abc\xE9def'[2:]
177
str2 = 'abc\xE9def'[:4]
178
str3 = 'abc\xE9def'[2:4]
180
return str0, str1, str2, str3
183
@cython.test_fail_if_path_exists(
186
def str_in_and_not_in():
188
>>> str_in_and_not_in()
191
if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': return True
195
@cython.test_fail_if_path_exists(
206
@cython.test_fail_if_path_exists(
209
def while_false_else():
211
>>> while_false_else()
220
@cython.test_fail_if_path_exists(
221
"//WhileStatNode//PrintStatNode",
222
"//WhileStatNode//PrimaryCmpNode",
223
"//WhileStatNode/BoolNode",
224
"//WhileStatNode/IntNode",
226
@cython.test_assert_path_exists(
240
@cython.test_fail_if_path_exists(
251
@cython.test_fail_if_path_exists(
254
def for_in_empty_else():
256
>>> for_in_empty_else()
265
@cython.test_fail_if_path_exists(
266
"//ComprehensionNode",
269
@cython.test_assert_path_exists(
272
def for_in_empty_listcomp():
274
>>> for_in_empty_listcomp()
277
return [i for i in []]
280
@cython.test_fail_if_path_exists(
281
"//ComprehensionNode",
284
@cython.test_assert_path_exists(
287
def for_in_empty_nested_listcomp():
289
>>> for_in_empty_nested_listcomp()
292
return [x for _ in [] for x in [1, 2, 3]]
295
@cython.test_fail_if_path_exists(
296
"//ForInStatNode//ForInStatNode",
298
@cython.test_assert_path_exists(
300
"//ComprehensionNode",
302
def for_in_nested_listcomp():
304
>>> for_in_nested_listcomp()
307
return [x for x in [1, 2, 3] for _ in []]
310
@cython.test_fail_if_path_exists(
313
def mult_empty_list():
315
>>> mult_empty_list()
321
@cython.test_fail_if_path_exists(
324
def mult_list_int_int():
326
>>> mult_list_int_int()
327
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
329
return [1, 2] * 2 * 3
332
@cython.test_fail_if_path_exists(
335
def mult_int_list_int():
337
>>> mult_int_list_int()
338
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
340
return 3 * [1, 2] * 2
343
@cython.test_fail_if_path_exists(
345
"//ListNode//IntNode",
352
return -5 * [1, 2] * -100
355
@cython.test_fail_if_path_exists(
357
"//ListNode//IntNode",
364
return 0 * [1, 2] * 0
367
@cython.test_assert_path_exists(
370
@cython.test_fail_if_path_exists(
373
"//ListNode//IntNode",
380
return 5 in 100 * [1, 2] * 0
383
@cython.test_assert_path_exists(
386
@cython.test_fail_if_path_exists(
389
"//ListNode//IntNode",
391
def not_in_mult_list():
393
>>> not_in_mult_list()
396
return 5 not in 100 * [1, 2] * 0
399
@cython.test_assert_path_exists(
402
@cython.test_fail_if_path_exists(
405
"//ListNode//IntNode",
412
return 5 in 100 * [1, 2] * 0 or 5 not in 100 * [] * 10
415
@cython.test_assert_path_exists(
416
'//IntNode[@base_10_value = "2"]',
417
'//IntNode[@base_10_value = "4"]',
418
'//IntNode[@base_10_value = "5"]',
419
'//IntNode[@base_10_value = "7"]',
420
'//BoolBinopNode//PrimaryCmpNode',
421
'//BoolBinopNode[.//PrimaryCmpNode//IntNode[@base_10_value = "4"] and .//PrimaryCmpNode//IntNode[@base_10_value = "5"]]',
422
'//PrimaryCmpNode[.//IntNode[@base_10_value = "2"] and .//IntNode[@base_10_value = "4"]]',
423
'//PrimaryCmpNode[.//IntNode[@base_10_value = "5"] and .//IntNode[@base_10_value = "7"]]',
425
@cython.test_fail_if_path_exists(
426
'//IntNode[@base_10_value = "1"]',
427
'//IntNode[@base_10_value = "8"]',
428
'//PrimaryCmpNode[.//IntNode[@base_10_value = "4"] and .//IntNode[@base_10_value = "5"]]',
429
'//PrimaryCmpNode[.//IntNode[@base_10_value = "2"] and .//IntNode[@base_10_value = "7"]]',
432
def cascaded_cmp_with_partial_constants(a, b):
434
>>> cascaded_cmp_with_partial_constants(3, 6)
436
>>> cascaded_cmp_with_partial_constants(1, 6)
438
>>> cascaded_cmp_with_partial_constants(4, 6)
440
>>> cascaded_cmp_with_partial_constants(3, 7)
442
>>> cascaded_cmp_with_partial_constants(3, 6)
445
return 1 < 2 < a < 4 < 5 < b < 7 < 8
448
@cython.test_assert_path_exists(
449
'//IntNode[@base_10_value = "2"]',
450
'//IntNode[@base_10_value = "4"]',
451
'//IntNode[@base_10_value = "5"]',
452
'//IntNode[@base_10_value = "7"]',
454
'//SingleAssignmentNode//BoolBinopNode',
455
'//SingleAssignmentNode//BoolBinopNode//NameNode[@name = "a"]',
456
'//SingleAssignmentNode//BoolBinopNode//NameNode[@name = "b"]',
457
'//BoolBinopNode[.//PrimaryCmpNode//IntNode[@base_10_value = "4"] and .//PrimaryCmpNode//IntNode[@base_10_value = "5"]]',
458
'//BoolNode[@value = False]',
460
@cython.test_fail_if_path_exists(
461
'//SingleAssignmentNode//NameNode[@name = "c"]',
462
'//IntNode[@base_10_value = "1"]',
463
'//PrimaryCmpNode[.//IntNode[@base_10_value = "4"] and .//IntNode[@base_10_value = "5"]]',
464
'//PrimaryCmpNode[.//IntNode[@base_10_value = "2"] and .//IntNode[@base_10_value = "7"]]',
465
'//BoolNode[@value = True]',
467
def cascaded_cmp_with_partial_constants_and_false_end(a, b, c):
469
>>> cascaded_cmp_with_partial_constants_and_false_end(3, 6, 8)
471
>>> cascaded_cmp_with_partial_constants_and_false_end(1, 6, 8)
473
>>> cascaded_cmp_with_partial_constants_and_false_end(4, 6, 8)
475
>>> cascaded_cmp_with_partial_constants_and_false_end(3, 7, 8)
478
x = 1 < 2 < a < 4 < 5 < b < 7 < 7 < c
482
@cython.test_assert_path_exists(
484
'//PrimaryCmpNode//IntNode',
485
'//PrimaryCmpNode//IntNode[@base_10_value = "0"]',
486
'//PrimaryCmpNode//IntNode[@base_10_value = "4294967296"]',
488
@cython.test_fail_if_path_exists(
489
'//PrimaryCmpNode//IntBinopNode',
490
'//PrimaryCmpNode//IntNode[@base_10_value = "1"]',
491
'//PrimaryCmpNode//IntNode[@base_10_value = "32"]',
493
def const_in_binop(v):
495
>>> const_in_binop(-1)
497
>>> const_in_binop(0)
499
>>> const_in_binop(1 << 32)
501
>>> const_in_binop(1 << 32 - 1)
504
if v < 0 or v >= (1 << 32):