Merged pull request #12 from bhy/T423.
[cython.git] / tests / run / bad_c_struct_T252.pyx
1 # ticket: 252
2
3 cdef cf(default=None):
4     return default
5
6 cpdef cpf(default=100):
7     """
8     >>> cpf()
9     100
10     >>> cpf(1)
11     1
12     >>> cpf(default=2)
13     2
14     """
15     default = cf(default)
16     return default
17
18 def pf(default=100):
19     """
20     >>> pf()
21     100
22     >>> pf(1)
23     1
24     >>> pf(default=2)
25     2
26     """
27     return default
28
29
30 cdef struct foo:
31     int void
32     int default
33
34 def test_struct():
35     """
36     >>> test_struct()
37     (1, 2)
38     """
39     cdef foo foo_struct
40     foo_struct.void = 1
41     foo_struct.default = 2
42     return foo_struct.void, foo_struct.default
43
44
45 cdef class Foo:
46     cdef int void
47     cdef int default
48
49 def test_class():
50     """
51     >>> test_class()
52     (1, 2)
53     """
54     cdef Foo foo_instance = Foo()
55     foo_instance.void = 1
56     foo_instance.default = 2
57     return foo_instance.void, foo_instance.default