1
# cython: language_level=3str
8
# avoid 'L' postfix in Py2.x
9
print(str(x).rstrip('L'))
12
# avoid 'L' postfix in Py2.x
13
print(str(x).replace('L', ''))
16
@cython.test_assert_path_exists('//IntBinopNode')
17
def or_obj(obj2, obj3):
26
@cython.test_fail_if_path_exists('//IntBinopNode')
40
@cython.test_assert_path_exists('//IntBinopNode')
41
def xor_obj(obj2, obj3):
50
@cython.test_fail_if_path_exists('//IntBinopNode')
64
@cython.test_assert_path_exists('//IntBinopNode')
65
def and_obj(obj2, obj3):
74
@cython.test_fail_if_path_exists('//IntBinopNode')
90
@cython.test_assert_path_exists('//IntBinopNode')
91
def lshift_obj(obj2, obj3):
100
@cython.test_assert_path_exists('//IntBinopNode')
101
def rshift_obj(obj2, obj3):
110
@cython.test_assert_path_exists('//IntBinopNode')
111
def rshift_int_obj(obj3):
113
>>> rshift_int_obj(3)
115
>>> rshift_int_obj(2)
117
>>> rshift_int_obj(1)
119
>>> rshift_int_obj(0)
121
>>> rshift_int_obj(-1)
122
Traceback (most recent call last):
123
ValueError: negative shift count
129
@cython.test_fail_if_path_exists('//IntBinopNode')
153
>>> rshift_int(2**28)
157
>>> rshift_int(-2**28)
162
>>> rshift_int(2**30)
164
>>> rshift_int(-2**30)
167
>>> bigint((2**60) >> 3)
169
>>> bigint(rshift_int(2**60))
171
>>> bigint(rshift_int(-2**60))
178
@cython.test_assert_path_exists(
179
'//SingleAssignmentNode//IntBinopNode',
180
'//SingleAssignmentNode//PythonCapiCallNode',
186
>>> bigints(lshift_int(1))
187
(8, 2147483648, 9223372036854775808, 10633823966279326983230456482242756608)
188
>>> bigints(lshift_int(-1))
189
(-8, -2147483648, -9223372036854775808, -10633823966279326983230456482242756608)
190
>>> bigints(lshift_int(2))
191
(16, 4294967296, 18446744073709551616, 21267647932558653966460912964485513216)
193
>>> bigints(lshift_int(27))
194
(216, 57982058496, 249031044995078946816, 287113247089541828547222325020554428416)
197
>>> bigints(lshift_int(-27))
198
(-216, -57982058496, -249031044995078946816, -287113247089541828547222325020554428416)
200
>>> bigints(lshift_int(32))
201
(256, 68719476736, 295147905179352825856, 340282366920938463463374607431768211456)
204
>>> bigints(lshift_int(-32))
205
(-256, -68719476736, -295147905179352825856, -340282366920938463463374607431768211456)
207
>>> bigint((2**28) << 3)
209
>>> bigints(lshift_int(2**28))
210
(2147483648, 576460752303423488, 2475880078570760549798248448, 2854495385411919762116571938898990272765493248)
211
>>> bigint((-2**28) << 3)
213
>>> bigints(lshift_int(-2**28))
214
(-2147483648, -576460752303423488, -2475880078570760549798248448, -2854495385411919762116571938898990272765493248)
216
>>> bigint((2**30) << 3)
218
>>> bigints(lshift_int(2**30))
219
(8589934592, 2305843009213693952, 9903520314283042199192993792, 11417981541647679048466287755595961091061972992)
220
>>> bigints(lshift_int(-2**30))
221
(-8589934592, -2305843009213693952, -9903520314283042199192993792, -11417981541647679048466287755595961091061972992)
223
>>> bigint((2**60) << 3)
225
>>> bigints(lshift_int(2**60))
226
(9223372036854775808, 2475880078570760549798248448, 10633823966279326983230456482242756608, 12259964326927110866866776217202473468949912977468817408)
227
>>> bigints(lshift_int(-2**60))
228
(-9223372036854775808, -2475880078570760549798248448, -10633823966279326983230456482242756608, -12259964326927110866866776217202473468949912977468817408)
234
return r1, r2, r3, r4
237
@cython.test_assert_path_exists(
239
'//IntBinopNode//IntBinopNode',
241
def mixed_obj(obj2, obj3):
246
obj1 = obj2 << obj3 | obj2 >> obj3
250
@cython.test_assert_path_exists(
252
'//IntBinopNode//PythonCapiCallNode',
254
@cython.test_fail_if_path_exists(
255
'//IntBinopNode//IntBinopNode',
268
obj1 = (obj2 ^ 0x10) | (obj2 & 0x01)
272
@cython.test_assert_path_exists('//PythonCapiCallNode')
273
@cython.test_fail_if_path_exists(
290
@cython.test_assert_path_exists('//PythonCapiCallNode')
291
@cython.test_fail_if_path_exists(
308
@cython.test_assert_path_exists('//PythonCapiCallNode')
309
@cython.test_assert_path_exists('//PrimaryCmpNode')
310
def equals_many(obj2):
313
(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
315
(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
317
(False, True, False, False, False, False, False, False, False, False, False, False, False, False, False)
319
(False, False, True, False, False, False, False, False, False, False, False, False, False, False, False)
320
>>> equals_many(2**30)
321
(False, False, False, True, False, False, False, False, False, False, False, False, False, False, False)
322
>>> equals_many(-2**30)
323
(False, False, False, False, True, False, False, False, False, False, False, False, False, False, False)
324
>>> equals_many(2**30-1)
325
(False, False, False, False, False, True, False, False, False, False, False, False, False, False, False)
326
>>> equals_many(-2**30+1)
327
(False, False, False, False, False, False, True, False, False, False, False, False, False, False, False)
328
>>> equals_many(2**32)
329
(False, False, False, False, False, False, False, True, False, False, False, False, False, False, False)
330
>>> equals_many(-2**32)
331
(False, False, False, False, False, False, False, False, True, False, False, False, False, False, False)
332
>>> equals_many(2**45-1)
333
(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False)
334
>>> equals_many(-2**45+1)
335
(False, False, False, False, False, False, False, False, False, False, True, False, False, False, False)
336
>>> equals_many(2**64)
337
(False, False, False, False, False, False, False, False, False, False, False, True, False, False, False)
338
>>> equals_many(-2**64)
339
(False, False, False, False, False, False, False, False, False, False, False, False, True, False, False)
340
>>> equals_many(2**64-1)
341
(False, False, False, False, False, False, False, False, False, False, False, False, False, True, False)
342
>>> equals_many(-2**64+1)
343
(False, False, False, False, False, False, False, False, False, False, False, False, False, False, True)
345
cdef bint x, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o
391
return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
394
@cython.test_assert_path_exists('//PythonCapiCallNode')
395
@cython.test_assert_path_exists('//PrimaryCmpNode')
396
def not_equals_many(obj2):
398
>>> not_equals_many(-2)
399
(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
400
>>> not_equals_many(0)
401
(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
402
>>> not_equals_many(1)
403
(False, True, False, False, False, False, False, False, False, False, False, False, False, False, False)
404
>>> not_equals_many(-1)
405
(False, False, True, False, False, False, False, False, False, False, False, False, False, False, False)
406
>>> not_equals_many(2**30)
407
(False, False, False, True, False, False, False, False, False, False, False, False, False, False, False)
408
>>> not_equals_many(-2**30)
409
(False, False, False, False, True, False, False, False, False, False, False, False, False, False, False)
410
>>> not_equals_many(2**30-1)
411
(False, False, False, False, False, True, False, False, False, False, False, False, False, False, False)
412
>>> not_equals_many(-2**30+1)
413
(False, False, False, False, False, False, True, False, False, False, False, False, False, False, False)
414
>>> not_equals_many(2**32)
415
(False, False, False, False, False, False, False, True, False, False, False, False, False, False, False)
416
>>> not_equals_many(-2**32)
417
(False, False, False, False, False, False, False, False, True, False, False, False, False, False, False)
418
>>> not_equals_many(2**45-1)
419
(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False)
420
>>> not_equals_many(-2**45+1)
421
(False, False, False, False, False, False, False, False, False, False, True, False, False, False, False)
422
>>> not_equals_many(2**64)
423
(False, False, False, False, False, False, False, False, False, False, False, True, False, False, False)
424
>>> not_equals_many(-2**64)
425
(False, False, False, False, False, False, False, False, False, False, False, False, True, False, False)
426
>>> not_equals_many(2**64-1)
427
(False, False, False, False, False, False, False, False, False, False, False, False, False, True, False)
428
>>> not_equals_many(-2**64+1)
429
(False, False, False, False, False, False, False, False, False, False, False, False, False, False, True)
431
cdef bint a, b, c, d, e, f, g, h, i, j, k, l, m, n, o
477
return tuple(not x for x in (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o))
480
@cython.test_assert_path_exists('//PythonCapiCallNode')
481
@cython.test_fail_if_path_exists(
485
def equals_zero(obj2):
512
@cython.test_fail_if_path_exists("//CoerceToBooleanNode")
513
@cython.test_fail_if_path_exists("//CoerceToPyTypeNode")
514
def test_avoid_if_coercion(obj):
515
if obj == 1: # this should not go through a Python intermediate
520
@cython.test_fail_if_path_exists('//AddNode')
521
@cython.test_fail_if_path_exists('//NumBinopNode')
522
@cython.test_fail_if_path_exists('//BinopNode')
523
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
524
def pure_add_int(obj2: int):
533
@cython.test_fail_if_path_exists('//SubNode')
534
@cython.test_fail_if_path_exists('//NumBinopNode')
535
@cython.test_fail_if_path_exists('//BinopNode')
536
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
537
def pure_sub_int(obj2: int):
546
@cython.test_fail_if_path_exists('//MulNode')
547
@cython.test_fail_if_path_exists('//NumBinopNode')
548
@cython.test_fail_if_path_exists('//BinopNode')
549
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
550
def pure_mul_int(obj2: int):
559
@cython.test_fail_if_path_exists('//PrimaryCmpNode')
560
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
561
def pure_eq_int(obj2: int):
572
@cython.test_fail_if_path_exists('//PrimaryCmpNode')
573
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
574
def pure_ne_int(obj2: int):
585
@cython.test_fail_if_path_exists('//IntBinopNode')
586
@cython.test_fail_if_path_exists('//NumBinopNode')
587
@cython.test_fail_if_path_exists('//BinopNode')
588
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
589
def pure_and_int(obj2: int):
600
@cython.test_fail_if_path_exists('//IntBinopNode')
601
@cython.test_fail_if_path_exists('//NumBinopNode')
602
@cython.test_fail_if_path_exists('//BinopNode')
603
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
604
def pure_or_int(obj2: int):
615
@cython.test_fail_if_path_exists('//IntBinopNode')
616
@cython.test_fail_if_path_exists('//NumBinopNode')
617
@cython.test_fail_if_path_exists('//BinopNode')
618
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
619
def pure_xor_int(obj2: int):
630
@cython.test_fail_if_path_exists('//IntBinopNode')
631
@cython.test_fail_if_path_exists('//NumBinopNode')
632
@cython.test_fail_if_path_exists('//BinopNode')
633
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
634
def pure_rshift_int(obj2: int):
636
>>> pure_rshift_int(8)
642
@cython.test_fail_if_path_exists('//IntBinopNode')
643
@cython.test_fail_if_path_exists('//NumBinopNode')
644
@cython.test_fail_if_path_exists('//BinopNode')
645
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
646
def pure_lshift_int(obj2: int):
648
>>> pure_lshift_int(8)
654
@cython.test_fail_if_path_exists('//IntBinopNode')
655
@cython.test_fail_if_path_exists('//NumBinopNode')
656
@cython.test_fail_if_path_exists('//BinopNode')
657
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
658
def pure_mod_int(obj2: int):
666
@cython.test_fail_if_path_exists('//DivNode')
667
@cython.test_fail_if_path_exists('//NumBinopNode')
668
@cython.test_fail_if_path_exists('//BinopNode')
669
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
670
def pure_floordiv_int(obj2: int):
672
>>> pure_floordiv_int(3)
681
@cython.test_fail_if_path_exists('//DivNode')
682
@cython.test_fail_if_path_exists('//NumBinopNode')
683
@cython.test_fail_if_path_exists('//BinopNode')
684
@cython.test_assert_path_exists('//PythonCapiFunctionNode')
685
def pure_truediv_int(obj2: int):
687
>>> pure_truediv_int(5)