6
text = u'ab jd sdflk as sa sadas asdas fsdf '
9
format2 = u'abc%sdef%sghi'
22
# unicode.split(s, [sep, [maxsplit]])
24
@cython.test_assert_path_exists(
25
"//PythonCapiCallNode")
31
... assert py == cy, (py, cy)
33
>>> print_all( test_split() )
45
@cython.test_assert_path_exists(
46
"//PythonCapiCallNode")
47
def split_sep(unicode s, sep):
49
>>> def test_split_sep(sep):
50
... py = text.split(sep)
51
... cy = split_sep(text, sep)
52
... assert py == cy, (py, cy)
54
>>> print_all( test_split_sep(sep) )
58
>>> print_all( test_split_sep(None) )
70
@cython.test_fail_if_path_exists(
71
"//CoerceToPyTypeNode",
72
"//CastNode", "//TypecastNode")
73
@cython.test_assert_path_exists(
74
"//CoerceFromPyTypeNode",
75
"//PythonCapiCallNode")
76
def split_sep_max(unicode s, sep, max):
78
>>> def test_split_sep_max(sep, max):
79
... py = text.split(sep, max)
80
... cy = split_sep_max(text, sep, max)
81
... assert py == cy, (py, cy)
83
>>> print_all( test_split_sep_max(sep, 1) )
85
sdflk as sa sadas asdas fsdf\x20
86
>>> print_all( test_split_sep_max(None, 2) )
89
sdflk as sa sadas asdas fsdf\x20
90
>>> print_all( text.split(None, 2) )
93
sdflk as sa sadas asdas fsdf\x20
94
>>> print_all( split_sep_max(text, None, 2) )
97
sdflk as sa sadas asdas fsdf\x20
99
return s.split(sep, max)
101
@cython.test_fail_if_path_exists(
102
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
103
"//CastNode", "//TypecastNode")
104
@cython.test_assert_path_exists(
105
"//PythonCapiCallNode")
106
def split_sep_max_int(unicode s, sep):
108
>>> def test_split_sep_max_int(sep):
109
... py = text.split(sep, 1)
110
... cy = split_sep_max_int(text, sep)
111
... assert py == cy, (py, cy)
113
>>> print_all( test_split_sep_max_int(sep) )
115
sdflk as sa sadas asdas fsdf\x20
116
>>> print_all( test_split_sep_max_int(None) )
118
jd sdflk as sa sadas asdas fsdf\x20
120
return s.split(sep, 1)
123
# unicode.splitlines(s, [keepends])
125
@cython.test_assert_path_exists(
126
"//PythonCapiCallNode")
127
def splitlines(unicode s):
129
>>> def test_splitlines(s):
130
... py = s.splitlines()
131
... cy = splitlines(s)
132
... assert py == cy, (py, cy)
134
>>> len(test_splitlines(multiline_text))
136
>>> print_all( test_splitlines(multiline_text) )
141
return s.splitlines()
143
@cython.test_assert_path_exists(
144
"//PythonCapiCallNode")
145
def splitlines_keep(unicode s, keep):
147
>>> def test_splitlines_keep(s, keep):
148
... py = s.splitlines(keep)
149
... cy = splitlines_keep(s, keep)
150
... assert py == cy, (py, cy)
152
>>> len(test_splitlines_keep(multiline_text, True))
154
>>> print_all( test_splitlines_keep(multiline_text, True) )
161
return s.splitlines(keep)
163
@cython.test_fail_if_path_exists(
164
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
165
"//CastNode", "//TypecastNode")
166
@cython.test_assert_path_exists(
167
"//PythonCapiCallNode")
168
def splitlines_keep_bint(unicode s):
170
>>> def test_splitlines_keep_bint(s):
171
... py = s.splitlines(True) + ['--'] + s.splitlines(False)
172
... cy = splitlines_keep_bint(s)
173
... assert py == cy, (py, cy)
175
>>> len(test_splitlines_keep_bint(multiline_text))
177
>>> print_all( test_splitlines_keep_bint(multiline_text) )
188
return s.splitlines(True) + ['--'] + s.splitlines(False)
191
# unicode.join(s, iterable)
195
@cython.test_fail_if_path_exists(
196
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
197
"//CastNode", "//TypecastNode",
198
"//SimpleCallNode//AttributeNode[@is_py_attr = true]")
199
@cython.test_assert_path_exists(
200
"//PythonCapiCallNode",
202
def join(unicode sep, l):
204
>>> def test_join(sep, l):
206
... cy = join(sep, l)
207
... assert py == cy, (py, cy)
212
>>> print( test_join(pipe_sep, l) )
213
ab|jd|sdflk|as|sa|sadas|asdas|fsdf
218
@cython.test_fail_if_path_exists(
219
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
220
"//CastNode", "//TypecastNode", "//NoneCheckNode",
221
"//SimpleCallNode//AttributeNode[@is_py_attr = true]")
222
@cython.test_assert_path_exists(
223
"//PythonCapiCallNode",
227
>>> def test_join_sep(l):
230
... assert py == cy, (py, cy)
235
>>> print( test_join_sep(l) )
236
ab|jd|sdflk|as|sa|sadas|asdas|fsdf
238
result = u'|'.join(l)
239
assert cython.typeof(result) == "str object", cython.typeof(result)
243
@cython.test_fail_if_path_exists(
244
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
245
"//CastNode", "//TypecastNode", "//NoneCheckNode",
246
"//SimpleCallNode//AttributeNode[@is_py_attr = true]"
248
@cython.test_assert_path_exists(
249
"//PythonCapiCallNode",
250
"//InlinedGeneratorExpressionNode"
252
def join_sep_genexpr(l):
254
>>> def test_join_sep_genexpr(l):
255
... py = '|'.join(s + ' ' for s in l)
256
... cy = join_sep_genexpr(l)
257
... assert py == cy, (py, cy)
262
>>> print( '<<%s>>' % test_join_sep_genexpr(l) )
263
<<ab |jd |sdflk |as |sa |sadas |asdas |fsdf >>
265
result = u'|'.join(s + u' ' for s in l)
266
assert cython.typeof(result) == "str object", cython.typeof(result)
270
@cython.test_fail_if_path_exists(
271
"//CoerceToPyTypeNode", "//CoerceFromPyTypeNode",
272
"//CastNode", "//TypecastNode",
274
@cython.test_assert_path_exists(
275
"//PythonCapiCallNode",
276
"//InlinedGeneratorExpressionNode"
278
def join_sep_genexpr_dictiter(dict d):
280
>>> def test_join_sep_genexpr_dictiter(d):
281
... py = '|'.join( sorted(' '.join('%s:%s' % (k, v) for k, v in d.items()).split()) )
282
... cy = '|'.join( sorted(join_sep_genexpr_dictiter(d).split()) )
283
... assert py == cy, (py, cy)
286
>>> d = dict(zip(range(len(l)), l))
287
>>> print( test_join_sep_genexpr_dictiter(d) )
288
0:ab|1:jd|2:sdflk|3:as|4:sa|5:sadas|6:asdas|7:fsdf
290
result = u' '.join('%s:%s' % (k, v) for k, v in d.iteritems())
291
assert cython.typeof(result) == "str object", cython.typeof(result)
295
@cython.test_assert_path_exists(
296
"//PythonCapiCallNode",
298
def join_unbound(unicode sep, l):
300
>>> def test_join_unbound(sep, l):
302
... cy = join_unbound(sep, l)
303
... assert py == cy, (py, cy)
308
>>> print( test_join_unbound(pipe_sep, l) )
309
ab|jd|sdflk|as|sa|sadas|asdas|fsdf
315
# unicode.startswith(s, prefix, [start, [end]])
317
@cython.test_fail_if_path_exists(
318
"//CoerceToPyTypeNode",
319
"//CoerceFromPyTypeNode",
320
"//CastNode", "//TypecastNode")
321
@cython.test_assert_path_exists(
322
"//PythonCapiCallNode")
323
def startswith(unicode s, sub):
325
>>> def test_startswith(s, sub):
326
... py = s.startswith(sub)
327
... cy = startswith(s, sub)
328
... assert py == cy, (py, cy)
330
>>> test_startswith(text, 'ab ')
332
>>> test_startswith(text, 'ab X')
335
>>> test_startswith(text, ('ab', 'ab '))
337
>>> not test_startswith(text, (' ab', 'ab X'))
340
if s.startswith(sub):
345
@cython.test_fail_if_path_exists(
346
"//CoerceToPyTypeNode",
347
"//CastNode", "//TypecastNode")
348
@cython.test_assert_path_exists(
349
"//CoerceFromPyTypeNode",
350
"//PythonCapiCallNode")
351
def startswith_start_end(unicode s, sub, start, end):
353
>>> def test_startswith_start_end(s, sub, start, end):
354
... py = s.startswith(sub, start, end)
355
... cy = startswith_start_end(s, sub, start, end)
356
... assert py == cy, (py, cy)
358
>>> test_startswith_start_end(text, 'b ', 1, 5)
360
>>> test_startswith_start_end(text, 'ab ', -1000, 5000)
362
>>> test_startswith_start_end(text, 'b X', 1, 5)
365
>>> test_startswith_start_end(text, 'ab ', None, None)
367
>>> test_startswith_start_end(text, 'ab ', 1, None)
369
>>> test_startswith_start_end(text, 'b ', 1, None)
371
>>> test_startswith_start_end(text, 'ab ', None, 3)
373
>>> test_startswith_start_end(text, 'ab ', None, 2)
376
if s.startswith(sub, start, end):
382
# unicode.endswith(s, prefix, [start, [end]])
384
@cython.test_fail_if_path_exists(
385
"//CoerceToPyTypeNode",
386
"//CoerceFromPyTypeNode",
387
"//CastNode", "//TypecastNode")
388
@cython.test_assert_path_exists(
389
"//PythonCapiCallNode")
390
def endswith(unicode s, sub):
392
>>> def test_endswith(s, sub):
393
... py = s.endswith(sub)
394
... cy = endswith(s, sub)
395
... assert py == cy, (py, cy)
397
>>> test_endswith(text, 'fsdf ')
399
>>> test_endswith(text, 'fsdf X')
402
>>> test_endswith(text, ('fsdf', 'fsdf '))
404
>>> test_endswith(text, ('fsdf', 'fsdf X'))
412
@cython.test_fail_if_path_exists(
413
"//CoerceToPyTypeNode",
414
"//CastNode", "//TypecastNode")
415
@cython.test_assert_path_exists(
416
"//CoerceFromPyTypeNode",
417
"//PythonCapiCallNode")
418
def endswith_start_end(unicode s, sub, start, end):
420
>>> def test_endswith_start_end(s, sub, start, end):
421
... py = s.endswith(sub, start, end)
422
... cy = endswith_start_end(s, sub, start, end)
423
... assert py == cy, (py, cy)
425
>>> test_endswith_start_end(text, 'fsdf', 10, len(text)-1)
427
>>> test_endswith_start_end(text, 'fsdf ', 10, len(text)-1)
430
>>> test_endswith_start_end(text, 'fsdf ', -1000, 5000)
433
>>> test_endswith_start_end(text, ('fsd', 'fsdf'), 10, len(text)-1)
435
>>> test_endswith_start_end(text, ('fsdf ', 'fsdf X'), 10, len(text)-1)
438
>>> test_endswith_start_end(text, 'fsdf ', None, None)
440
>>> test_endswith_start_end(text, 'fsdf ', 32, None)
442
>>> test_endswith_start_end(text, 'fsdf ', 33, None)
444
>>> test_endswith_start_end(text, 'fsdf ', None, 37)
446
>>> test_endswith_start_end(text, 'fsdf ', None, 36)
449
if s.endswith(sub, start, end):
455
# unicode.__contains__(s, sub)
457
@cython.test_fail_if_path_exists(
458
"//CoerceFromPyTypeNode", "//AttributeNode")
459
@cython.test_assert_path_exists(
460
"//CoerceToPyTypeNode", "//PrimaryCmpNode")
461
def in_test(unicode s, substring):
463
>>> in_test(text, 'sa')
465
>>> in_test(text, 'XYZ')
467
>>> in_test(None, 'sa')
468
Traceback (most recent call last):
469
TypeError: 'NoneType' object is not iterable
471
return substring in s
474
# unicode.__concat__(s, suffix)
476
def concat_any(unicode s, suffix):
478
>>> concat(text, 'sa') == text + 'sa' or concat(text, 'sa')
480
>>> concat(None, 'sa') # doctest: +ELLIPSIS
481
Traceback (most recent call last):
483
>>> concat(text, None) # doctest: +ELLIPSIS
484
Traceback (most recent call last):
486
>>> class RAdd(object):
487
... def __radd__(self, other):
489
>>> concat(None, 'sa') # doctest: +ELLIPSIS
490
Traceback (most recent call last):
493
assert cython.typeof(s + suffix) == 'Python object', cython.typeof(s + suffix)
497
def concat(unicode s, str suffix):
499
>>> concat(text, 'sa') == text + 'sa' or concat(text, 'sa')
501
>>> concat(None, 'sa') # doctest: +ELLIPSIS
502
Traceback (most recent call last):
504
>>> concat(text, None) # doctest: +ELLIPSIS
505
Traceback (most recent call last):
507
>>> class RAdd(object):
508
... def __radd__(self, other):
510
>>> concat(None, 'sa') # doctest: +ELLIPSIS
511
Traceback (most recent call last):
514
assert cython.typeof(s + object()) == 'Python object', cython.typeof(s + object())
515
assert cython.typeof(s + suffix) == "str object", cython.typeof(s + suffix)
519
def concat_literal_str(str suffix):
521
>>> concat_literal_str('sa') == 'abcsa' or concat_literal_str('sa')
523
>>> concat_literal_str(None) # doctest: +ELLIPSIS
524
Traceback (most recent call last):
525
TypeError: ...NoneType...
527
assert cython.typeof(u'abc' + object()) == 'Python object', cython.typeof(u'abc' + object())
528
assert cython.typeof(u'abc' + suffix) == "str object", cython.typeof(u'abc' + suffix)
529
return u'abc' + suffix
532
def concat_literal_unicode(unicode suffix):
534
>>> concat_literal_unicode(unicode_sa) == 'abcsa' or concat_literal_unicode(unicode_sa)
536
>>> concat_literal_unicode(None) # doctest: +ELLIPSIS
537
Traceback (most recent call last):
538
TypeError: ...NoneType...
540
assert cython.typeof(u'abc' + suffix) == "str object", cython.typeof(u'abc' + suffix)
541
return u'abc' + suffix
544
# unicode.__mod__(format, values)
546
def mod_format(unicode s, values):
548
>>> mod_format(format1, 'sa') == 'abcsadef' or mod_format(format1, 'sa')
550
>>> mod_format(format2, ('XYZ', 'ABC')) == 'abcXYZdefABCghi' or mod_format(format2, ('XYZ', 'ABC'))
553
Exact TypeError message is different in PyPy
554
>>> mod_format(None, 'sa') # doctest: +IGNORE_EXCEPTION_DETAIL
555
Traceback (most recent call last):
556
TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'
557
>>> class RMod(object):
558
... def __rmod__(self, other):
560
>>> mod_format(None, RMod())
563
assert cython.typeof(s % values) == 'Python object', cython.typeof(s % values)
567
def mod_format_literal(values):
569
>>> mod_format_literal('sa') == 'abcsadef' or mod_format(format1, 'sa')
571
>>> mod_format_literal(('sa',)) == 'abcsadef' or mod_format(format1, ('sa',))
573
>>> mod_format_literal(['sa']) == "abc['sa']def" or mod_format(format1, ['sa'])
576
assert cython.typeof(u'abc%sdef' % values) == "str object", cython.typeof(u'abc%sdef' % values)
577
return u'abc%sdef' % values
580
def mod_format_tuple(*values):
582
>>> mod_format_tuple('sa') == 'abcsadef' or mod_format(format1, 'sa')
584
>>> mod_format_tuple()
585
Traceback (most recent call last):
586
TypeError: not enough arguments for format string
588
assert cython.typeof(u'abc%sdef' % values) == "str object", cython.typeof(u'abc%sdef' % values)
589
return u'abc%sdef' % values
592
# unicode.find(s, sub, [start, [end]])
594
@cython.test_fail_if_path_exists(
595
"//CoerceFromPyTypeNode",
596
"//CastNode", "//TypecastNode")
597
@cython.test_assert_path_exists(
598
"//CoerceToPyTypeNode",
599
"//PythonCapiCallNode")
600
def find(unicode s, substring):
602
>>> def test_find(s, substring):
603
... py = s.find(substring)
604
... cy = find(s, substring)
605
... assert py == cy, (py, cy)
607
>>> test_find(text, 'sa')
610
cdef Py_ssize_t pos = s.find(substring)
613
@cython.test_fail_if_path_exists(
614
"//CastNode", "//TypecastNode")
615
@cython.test_assert_path_exists(
616
"//CoerceToPyTypeNode",
617
"//PythonCapiCallNode")
618
def find_start_end(unicode s, substring, start, end):
620
>>> def test_find_start_end(s, substring, start, end):
621
... py = s.find(substring, start, end)
622
... cy = find_start_end(s, substring, start, end)
623
... assert py == cy, (py, cy)
625
>>> test_find_start_end(text, 'sa', 17, 25)
627
>>> test_find_start_end(text, 'sa', None, None)
629
>>> test_find_start_end(text, 'sa', 16, None)
631
>>> test_find_start_end(text, 'sa', 17, None)
633
>>> test_find_start_end(text, 'sa', None, 16)
635
>>> test_find_start_end(text, 'sa', None, 19)
638
cdef Py_ssize_t pos = s.find(substring, start, end)
642
# unicode.rfind(s, sub, [start, [end]])
644
@cython.test_fail_if_path_exists(
645
"//CoerceFromPyTypeNode",
646
"//CastNode", "//TypecastNode")
647
@cython.test_assert_path_exists(
648
"//CoerceToPyTypeNode",
649
"//PythonCapiCallNode")
650
def rfind(unicode s, substring):
652
>>> def test_rfind(s, substring):
653
... py = s.rfind(substring)
654
... cy = rfind(s, substring)
655
... assert py == cy, (py, cy)
657
>>> test_rfind(text, 'sa')
660
cdef Py_ssize_t pos = s.rfind(substring)
663
@cython.test_fail_if_path_exists(
664
"//CastNode", "//TypecastNode")
665
@cython.test_assert_path_exists(
666
"//CoerceToPyTypeNode",
667
"//PythonCapiCallNode")
668
def rfind_start_end(unicode s, substring, start, end):
670
>>> def test_rfind_start_end(s, substring, start, end):
671
... py = s.rfind(substring, start, end)
672
... cy = rfind_start_end(s, substring, start, end)
673
... assert py == cy, (py, cy)
675
>>> test_rfind_start_end(text, 'sa', 14, 19)
677
>>> test_rfind_start_end(text, 'sa', None, None)
679
>>> test_rfind_start_end(text, 'sa', 16, None)
681
>>> test_rfind_start_end(text, 'sa', 21, None)
683
>>> test_rfind_start_end(text, 'sa', None, 22)
685
>>> test_rfind_start_end(text, 'sa', None, 21)
688
cdef Py_ssize_t pos = s.rfind(substring, start, end)
692
# unicode.count(s, sub, [start, [end]])
694
@cython.test_fail_if_path_exists(
695
"//CoerceFromPyTypeNode",
696
"//CastNode", "//TypecastNode")
697
@cython.test_assert_path_exists(
698
"//CoerceToPyTypeNode",
699
"//PythonCapiCallNode")
700
def count(unicode s, substring):
702
>>> def test_count(s, substring):
703
... py = s.count(substring)
704
... cy = count(s, substring)
705
... assert py == cy, (py, cy)
707
>>> test_count(text, 'sa')
710
cdef Py_ssize_t pos = s.count(substring)
713
@cython.test_fail_if_path_exists(
714
"//CastNode", "//TypecastNode")
715
@cython.test_assert_path_exists(
716
"//CoerceToPyTypeNode",
717
"//PythonCapiCallNode")
718
def count_start_end(unicode s, substring, start, end):
720
>>> def test_count_start_end(s, substring, start, end):
721
... py = s.count(substring, start, end)
722
... cy = count_start_end(s, substring, start, end)
723
... assert py == cy, (py, cy)
725
>>> test_count_start_end(text, 'sa', 14, 21)
727
>>> test_count_start_end(text, 'sa', 14, 22)
729
>>> test_count_start_end(text, 'sa', None, None)
731
>>> test_count_start_end(text, 'sa', 14, None)
733
>>> test_count_start_end(text, 'sa', 17, None)
735
>>> test_count_start_end(text, 'sa', None, 23)
737
>>> test_count_start_end(text, 'sa', None, 20)
740
cdef Py_ssize_t pos = s.count(substring, start, end)
744
# unicode.replace(s, sub, repl, [maxcount])
746
@cython.test_fail_if_path_exists(
747
"//CoerceFromPyTypeNode",
748
"//CastNode", "//TypecastNode")
749
@cython.test_assert_path_exists(
750
"//PythonCapiCallNode")
751
def replace(unicode s, substring, repl):
753
>>> def test_replace(s, substring, repl):
754
... py = s.replace(substring, repl)
755
... cy = replace(s, substring, repl)
756
... assert py == cy, (py, cy)
758
>>> print( test_replace(text, 'sa', 'SA') )
759
ab jd sdflk as SA SAdas asdas fsdf\x20
761
return s.replace(substring, repl)
763
@cython.test_fail_if_path_exists(
764
"//CastNode", "//TypecastNode")
765
@cython.test_assert_path_exists(
766
"//CoerceFromPyTypeNode",
767
"//PythonCapiCallNode")
768
def replace_maxcount(unicode s, substring, repl, maxcount):
770
>>> def test_replace_maxcount(s, substring, repl, maxcount):
771
... py = s.replace(substring, repl, maxcount)
772
... cy = replace_maxcount(s, substring, repl, maxcount)
773
... assert py == cy, (py, cy)
775
>>> print( test_replace_maxcount(text, 'sa', 'SA', 1) )
776
ab jd sdflk as SA sadas asdas fsdf\x20
778
return s.replace(substring, repl, maxcount)
783
@cython.test_fail_if_path_exists(
784
"//CoerceToPyTypeNode",
786
@cython.test_assert_path_exists(
787
"//MulNode[@is_sequence_mul = True]",
789
def multiply(unicode ustring, int mul):
792
>>> ustr = u"abcüöä\\U0001F642"
794
>>> print(multiply(astr, -1))
796
>>> print(multiply(ustr, -1))
799
>>> print(multiply(astr, 0))
801
>>> print(multiply(ustr, 0))
804
>>> print(multiply(astr, 1))
806
>>> print(multiply(ustr, 1))
809
>>> print(multiply(astr, 2))
811
>>> print(multiply(ustr, 2))
812
abcüöä\U0001F642abcüöä\U0001F642
814
>>> print(multiply(astr, 5))
816
>>> print(multiply(ustr, 5))
817
abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642
822
@cython.test_fail_if_path_exists(
823
"//CoerceToPyTypeNode",
825
@cython.test_assert_path_exists(
826
"//MulNode[@is_sequence_mul = True]",
828
def multiply_call(ustring, int mul):
831
>>> ustr = u"abcüöä\\U0001F642"
833
>>> print(multiply_call(astr, 2))
835
>>> print(multiply_call(ustr, 2))
836
abcüöä\U0001F642abcüöä\U0001F642
838
return unicode(ustring) * mul
841
#@cython.test_fail_if_path_exists(
842
# "//CoerceToPyTypeNode",
843
# "//CastNode", "//TypecastNode")
844
#@cython.test_assert_path_exists(
845
# "//PythonCapiCallNode")
846
def multiply_inplace(unicode ustring, int mul):
849
>>> ustr = u"abcüöä\\U0001F642"
851
>>> print(multiply_inplace(astr, -1))
853
>>> print(multiply_inplace(ustr, -1))
856
>>> print(multiply_inplace(astr, 0))
858
>>> print(multiply_inplace(ustr, 0))
861
>>> print(multiply_inplace(astr, 1))
863
>>> print(multiply_inplace(ustr, 1))
866
>>> print(multiply_inplace(astr, 2))
868
>>> print(multiply_inplace(ustr, 2))
869
abcüöä\U0001F642abcüöä\U0001F642
871
>>> print(multiply_inplace(astr, 5))
873
>>> print(multiply_inplace(ustr, 5))
874
abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642
880
@cython.test_fail_if_path_exists(
881
"//CoerceToPyTypeNode",
883
@cython.test_assert_path_exists(
884
"//MulNode[@is_sequence_mul = True]",
886
def multiply_reversed(unicode ustring, int mul):
889
>>> ustr = u"abcüöä\\U0001F642"
891
>>> print(multiply_reversed(astr, -1))
893
>>> print(multiply_reversed(ustr, -1))
896
>>> print(multiply_reversed(astr, 0))
898
>>> print(multiply_reversed(ustr, 0))
901
>>> print(multiply_reversed(astr, 1))
903
>>> print(multiply_reversed(ustr, 1))
906
>>> print(multiply_reversed(astr, 2))
908
>>> print(multiply_reversed(ustr, 2))
909
abcüöä\U0001F642abcüöä\U0001F642
911
>>> print(multiply_reversed(astr, 5))
913
>>> print(multiply_reversed(ustr, 5))
914
abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642
919
@cython.test_fail_if_path_exists(
920
"//CoerceToPyTypeNode",
922
def unicode__mul__(unicode ustring, int mul):
925
>>> ustr = u"abcüöä\\U0001F642"
927
>>> print(unicode__mul__(astr, -1))
929
>>> print(unicode__mul__(ustr, -1))
932
>>> print(unicode__mul__(astr, 0))
934
>>> print(unicode__mul__(ustr, 0))
937
>>> print(unicode__mul__(astr, 1))
939
>>> print(unicode__mul__(ustr, 1))
942
>>> print(unicode__mul__(astr, 2))
944
>>> print(unicode__mul__(ustr, 2))
945
abcüöä\U0001F642abcüöä\U0001F642
947
>>> print(unicode__mul__(astr, 5))
949
>>> print(unicode__mul__(ustr, 5))
950
abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642abcüöä\U0001F642
952
return ustring.__mul__(mul)