1# ticket: 446
2
3import cython
4
5cdef extern from "complex_int_T446_fix.h":
6    pass
7
8def test_arith(int complex a, int complex b):
9    """
10    >>> test_arith(4, 2)
11    ((-4+0j), (6+0j), (2+0j), (8+0j))
12    >>> test_arith(6+9j, 3j)
13    ((-6-9j), (6+12j), (6+6j), (-27+18j))
14    >>> test_arith(29+11j, 5+7j)
15    ((-29-11j), (34+18j), (24+4j), (68+258j))
16    """
17    return -a, a+b, a-b, a*b
18
19@cython.cdivision(False)
20def test_div_by_zero(long complex z):
21    """
22    >>> test_div_by_zero(4j)
23    -25j
24    >>> test_div_by_zero(0)
25    Traceback (most recent call last):
26    ...
27    ZeroDivisionError: float division
28    """
29    return 100/z
30
31def test_coercion(int a, long b, int complex c):
32    """
33    >>> test_coercion(1, -2, 3-3j)
34    (1+0j)
35    (-2+0j)
36    (3-3j)
37    (5-6j)
38    """
39    cdef double complex z
40    z = a; print z
41    z = b; print z
42    z = c; print z
43    return z + a + b + c
44
45
46def test_conjugate(long complex z):
47    """
48    >>> test_conjugate(2+3j)
49    (2-3j)
50    """
51    return z.conjugate()
52
53def test_conjugate2(short complex z):
54    """
55    >>> test_conjugate2(2+3j)
56    (2-3j)
57    """
58    return z.conjugate()
59
60def test_conjugate3(long long complex z):
61    """
62    >>> test_conjugate3(2+3j)
63    (2-3j)
64    """
65    return z.conjugate()
66