From 3fbd62b793ff3e6b70ccf9ff495793b282c0f0f1 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 30 Jan 2010 16:35:06 -0800 Subject: [PATCH] Tests for ticket #445. --- tests/run/complex_cast_T445.pyx | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/run/complex_cast_T445.pyx diff --git a/tests/run/complex_cast_T445.pyx b/tests/run/complex_cast_T445.pyx new file mode 100644 index 00000000..d64c685c --- /dev/null +++ b/tests/run/complex_cast_T445.pyx @@ -0,0 +1,47 @@ +def complex_double_cast(double x, double complex z): + """ + >>> complex_double_cast(1, 4-3j) + ((1+0j), (4-3j)) + """ + cdef double complex xx = x + cdef double complex zz = z + xx = x + return xx, zz + +def complex_double_int_cast(int x, int complex z): + """ + >>> complex_double_int_cast(2, 2 + 3j) + ((2+0j), (3+3j)) + """ + cdef double complex xx = x + cdef double complex zz = (z+1) + return xx, zz + +def complex_int_double_cast(double x, double complex z): + """ + >>> complex_int_double_cast(2.5, 2.5 + 3.5j) + ((2+0j), (2+3j)) + """ + cdef int complex xx = x + cdef int complex zz = z + return xx, zz + +cdef int side_effect_counter = 0 + +cdef double complex side_effect(double complex z): + global side_effect_counter + side_effect_counter += 1 + print "side effect", side_effect_counter, z + return z + +def test_side_effect(int complex z): + """ + >>> test_side_effect(5) + side effect 1 (5+0j) + (5+0j) + >>> test_side_effect(3-4j) + side effect 2 (3-4j) + (3-4j) + """ + cdef int complex zz = side_effect(z) + return zz -- 2.26.2