extended test case
authorStefan Behnel <scoder@users.berlios.de>
Tue, 20 Apr 2010 06:25:35 +0000 (08:25 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 20 Apr 2010 06:25:35 +0000 (08:25 +0200)
tests/run/for_in_string.pyx

index 1ad0cfa23af7a4e795410af4078433243247697a..a892d1a5433e762a10c73d99998fecc04f715807 100644 (file)
@@ -1,3 +1,4 @@
+cimport cython
 
 bytes_abc = b'abc'
 bytes_ABC = b'ABC'
@@ -20,6 +21,8 @@ def for_in_bytes(bytes s):
     else:
         return 'X'
 
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
 def for_char_in_bytes(bytes s):
     """
     >>> for_char_in_bytes(bytes_abc)
@@ -34,6 +37,25 @@ def for_char_in_bytes(bytes s):
     else:
         return 'X'
 
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
+def for_char_in_enumerate_bytes(bytes s):
+    """
+    >>> for_char_in_enumerate_bytes(bytes_abc)
+    'X'
+    >>> for_char_in_enumerate_bytes(bytes_ABC)
+    2
+    """
+    cdef char c
+    cdef Py_ssize_t i
+    for i, c in enumerate(s):
+        if c == b'C':
+            return i
+    else:
+        return 'X'
+
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
 def for_pyunicode_in_unicode(unicode s):
     """
     >>> for_pyunicode_in_unicode(unicode_abc)
@@ -47,3 +69,20 @@ def for_pyunicode_in_unicode(unicode s):
             return 'C'
     else:
         return 'X'
+
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
+def for_pyunicode_in_enumerate_unicode(unicode s):
+    """
+    >>> for_pyunicode_in_enumerate_unicode(unicode_abc)
+    'X'
+    >>> for_pyunicode_in_enumerate_unicode(unicode_ABC)
+    2
+    """
+    cdef Py_UNICODE c
+    cdef Py_ssize_t i
+    for i, c in enumerate(s):
+        if c == u'C':
+            return i
+    else:
+        return 'X'