From: Stefan Behnel Date: Wed, 28 Oct 2009 13:29:21 +0000 (+0100) Subject: extended test case for ticket 252 X-Git-Tag: 0.12.alpha0~11^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=85e7bd5a54e636897343515c0803a9b3c239a4de;p=cython.git extended test case for ticket 252 --HG-- rename : tests/compile/bad_c_struct_T252.pyx => tests/run/bad_c_struct_T252.pyx --- diff --git a/tests/compile/bad_c_struct_T252.pyx b/tests/compile/bad_c_struct_T252.pyx deleted file mode 100644 index 0f5b959e..00000000 --- a/tests/compile/bad_c_struct_T252.pyx +++ /dev/null @@ -1,8 +0,0 @@ -cdef f(void=None): - pass - -cdef struct foo: - int void - -cdef class Foo: - cdef int void diff --git a/tests/run/bad_c_struct_T252.pyx b/tests/run/bad_c_struct_T252.pyx new file mode 100644 index 00000000..7c26b552 --- /dev/null +++ b/tests/run/bad_c_struct_T252.pyx @@ -0,0 +1,56 @@ + +cdef cf(default=None): + return default + +cpdef cpf(default=None): + """ + >>> cpf() + None + >>> cpf(1) + 1 + >>> cpf(default=2) + 2 + """ + default = cf(default) + return default + +def pf(default=None): + """ + >>> pf() + None + >>> pf(1) + 1 + >>> pf(default=2) + 2 + """ + return default + + +cdef struct foo: + int void + int default + +def test_struct(): + """ + >>> test_struct() + (1, 2) + """ + cdef foo foo_struct + foo_struct.void = 1 + foo_struct.default = 2 + return foo_struct.void, foo_struct.default + + +cdef class Foo: + cdef int void + cdef int default + +def test_class(): + """ + >>> test_class() + (1, 2) + """ + cdef Foo foo_instance = Foo() + foo_instance.void = 1 + foo_instance.default = 2 + return foo_instance.void, foo_instance.default