From 955537752ad67bcaecbd2f66d4c64a28983a45c5 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 4 Apr 2013 19:01:35 +0200 Subject: [PATCH] extend test case --- tests/run/exttype_freelist.pyx | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/run/exttype_freelist.pyx b/tests/run/exttype_freelist.pyx index 8cef318..40cafcd 100644 --- a/tests/run/exttype_freelist.pyx +++ b/tests/run/exttype_freelist.pyx @@ -156,6 +156,91 @@ def test_cmethods(ExtTypeWithCMethods obj not None): return x, obj.get_cattr() +cdef class ExtSubTypeWithCMethods(ExtTypeWithCMethods): + """ + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + """ + + +cdef class ExtSubTypeWithMoreCMethods(ExtSubTypeWithCMethods): + """ + >>> obj = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj) + (2, 3, 3) + >>> obj = ExtSubTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + >>> obj = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj) + (2, 3, 3) + >>> obj2 = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj2) + (2, 3, 3) + >>> obj2 = ExtSubTypeWithCMethods() + >>> test_cmethods(obj2) + (1, 2) + >>> obj = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj) + (2, 3, 3) + >>> obj2 = ExtTypeWithCMethods() + >>> test_cmethods(obj2) + (1, 2) + >>> obj = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj) + (2, 3, 3) + >>> obj2 = ExtSubTypeWithCMethods() + >>> test_cmethods(obj2) + (1, 2) + >>> obj = ExtSubTypeWithMoreCMethods() + >>> test_more_cmethods(obj) + (2, 3, 3) + >>> obj2 = ExtSubTypeWithCMethods() + >>> test_cmethods(obj2) + (1, 2) + >>> obj = ExtTypeWithCMethods() + >>> test_cmethods(obj) + (1, 2) + """ + def __cinit__(self): + assert self.cattr == 1 + self.cattr = 2 + + cdef int get_cattr2(self): + return self.cattr + + cdef set_cattr2(self, int value): + self.cattr = value + + +def test_more_cmethods(ExtSubTypeWithMoreCMethods obj not None): + x = obj.get_cattr() + assert obj.get_cattr2() == x + obj.set_cattr2(2) + assert obj.get_cattr2() == 2 + obj.set_cattr(3) + return x, obj.get_cattr(), obj.get_cattr2() + + @cython.freelist(4) cdef class ExtTypeWithRefCycle: """ -- 2.7.4