Commit e8527c58 authored by Stefan Behnel's avatar Stefan Behnel

extended test case

parent ebc07231
...@@ -183,3 +183,44 @@ def for_pyunicode_in_enumerate_unicode(unicode s): ...@@ -183,3 +183,44 @@ def for_pyunicode_in_enumerate_unicode(unicode s):
return i return i
else: else:
return 'X' return 'X'
@cython.test_assert_path_exists("//ForFromStatNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
def for_pyucs4_in_unicode(unicode s):
"""
>>> for_pyucs4_in_unicode(unicode_abc)
'X'
>>> for_pyucs4_in_unicode(unicode_ABC)
'C'
>>> for_pyucs4_in_unicode(unicode_abc_null)
'X'
>>> for_pyucs4_in_unicode(unicode_ABC_null)
'C'
"""
cdef Py_UCS4 c
for c in s:
if c == u'C':
return 'C'
else:
return 'X'
@cython.test_assert_path_exists("//ForFromStatNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
def for_pyucs4_in_enumerate_unicode(unicode s):
"""
>>> for_pyucs4_in_enumerate_unicode(unicode_abc)
'X'
>>> for_pyucs4_in_enumerate_unicode(unicode_ABC)
2
>>> for_pyucs4_in_enumerate_unicode(unicode_abc_null)
'X'
>>> for_pyucs4_in_enumerate_unicode(unicode_ABC_null)
4
"""
cdef Py_UCS4 c
cdef Py_ssize_t i
for i, c in enumerate(s):
if c == u'C':
return i
else:
return 'X'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment