603611753ac270616e5691dcffb6742a42fbbc69
[cython.git] / tests / run / builtincomplex.pyx
1
2 from cpython.complex cimport complex
3
4 def complex_attributes():
5     """
6     >>> complex_attributes()
7     (1.0, 2.0)
8     """
9     cdef complex c = 1+2j
10     return (c.real, c.imag)
11
12 def complex_attributes_assign():
13     """
14     >>> complex_attributes_assign()
15     (10.0, 20.0)
16     """
17     cdef complex c = 1+2j
18     c.cval.real, c.cval.imag = 10, 20
19     return (c.real, c.imag)
20
21 def complex_cstruct_assign():
22     """
23     >>> complex_cstruct_assign()
24     (10.0, 20.0)
25     """
26     cdef complex c = 1+2j
27     cval = &c.cval
28     cval.real, cval.imag = 10, 20
29     return (c.real, c.imag)