simple test case for safe double inference
authorStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 13:04:20 +0000 (14:04 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 13:04:20 +0000 (14:04 +0100)
tests/run/type_inference.pyx

index 3ba8e0bf58a501ec60af055b4a0a265b145ad9dd..ffc03cb2525df2716ab5ebfd5d190243615033b5 100644 (file)
@@ -1,6 +1,7 @@
 # cython: infer_types = all
 
 
+cimport cython
 from cython cimport typeof, infer_types
 
 cdef class MyType:
@@ -147,6 +148,23 @@ def loop():
         pass
     assert typeof(a) == "long"
 
+
+@cython.test_fail_if_path_exists('//NameNode[@type.is_pyobject = True]')
+@cython.test_assert_path_exists('//InPlaceAssignmentNode/NameNode',
+                                '//NameNode[@type.is_pyobject]',
+                                '//NameNode[@type.is_pyobject = False]')
+@infer_types('safe')
+def double_loop():
+    """
+    >>> double_loop() == 1.0 * 10
+    True
+    """
+    cdef int i
+    d = 1.0
+    for i in range(9):
+        d += 1.0
+    return d
+
 cdef unicode retu():
     return u"12345"