From 3060b7f16b0b8871b3c9b810fab1e5a2912cdf33 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 30 Mar 2011 21:10:49 +0200 Subject: [PATCH] extended test case, includes attribute access testing --- tests/run/closure_self.pyx | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/run/closure_self.pyx b/tests/run/closure_self.pyx index 78c544e1..60c256d4 100644 --- a/tests/run/closure_self.pyx +++ b/tests/run/closure_self.pyx @@ -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 -- 2.26.2