extended test case, includes attribute access testing
authorStefan Behnel <scoder@users.berlios.de>
Wed, 30 Mar 2011 19:10:49 +0000 (21:10 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 30 Mar 2011 19:10:49 +0000 (21:10 +0200)
tests/run/closure_self.pyx

index 78c544e1d8a9592e2175907394162fcebddf2b9b..60c256d4c4ae741eebdabe20282466a0a1edfd3b 100644 (file)
@@ -1,11 +1,38 @@
+cdef class Test:
+    cdef int x
+
 cdef class SelfInClosure(object):
-    """
-    >>> o = SelfInClosure()
-    >>> o.closure_method()() == o
-    True
-    """
+    cdef Test _t
+    cdef int x
+
+    def plain(self):
+        """
+        >>> o = SelfInClosure()
+        >>> o.plain()
+        1
+        """
+        self.x = 1
+        return self.x
 
     def closure_method(self):
+        """
+        >>> o = SelfInClosure()
+        >>> o.closure_method()() == o
+        True
+        """
         def nested():
             return self
         return nested
+
+    def closure_method_cdef_attr(self, Test t):
+        """
+        >>> o = SelfInClosure()
+        >>> o.closure_method_cdef_attr(Test())()
+        (1, 2)
+        """
+        t.x = 2
+        self._t = t
+        self.x = 1
+        def nested():
+            return self.x, t.x
+        return nested