From ab0acc7a1d11df70707c80610528904fb2fa0196 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 31 Oct 2009 13:42:53 -0700 Subject: [PATCH] Fix complex zero division testing. --- Cython/Compiler/ExprNodes.py | 1 + tests/run/complex_numbers_T305.pyx | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 90a0671c..bd6b2ff8 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5536,6 +5536,7 @@ class CoercionNode(ExprNode): # arg ExprNode node being coerced subexprs = ['arg'] + constant_result = not_a_constant def __init__(self, arg): self.pos = arg.pos diff --git a/tests/run/complex_numbers_T305.pyx b/tests/run/complex_numbers_T305.pyx index f07dcffe..e59e0a41 100644 --- a/tests/run/complex_numbers_T305.pyx +++ b/tests/run/complex_numbers_T305.pyx @@ -1,6 +1,3 @@ -#cdef extern from "complex.h": -# pass - cimport cython def test_object_conversion(o): @@ -23,21 +20,20 @@ def test_arithmetic(double complex z, double complex w): ((6+12j), (-6-12j), (6+15j), (6+9j), (-36+18j), (4-2j)) >>> test_arithmetic(5-10j, 3+4j) ((5-10j), (-5+10j), (8-6j), (2-14j), (55-10j), (-1-2j)) - - ## XXX this is not working - ## >>> test_div_by_zero(4j) - ## -0.25j - ## >>> test_div_by_zero(0) - ## Traceback (most recent call last): - ## ... - ## ZeroDivisionError: float division """ return +z, -z, z+w, z-w, z*w, z/w -## XXX this is not working -## @cython.cdivision(False) -## def test_div_by_zero(double complex z): -## return 1/z +@cython.cdivision(False) +def test_div_by_zero(double complex z): + """ + >>> test_div_by_zero(4j) + -0.25j + >>> test_div_by_zero(0) + Traceback (most recent call last): + ... + ZeroDivisionError: float division + """ + return 1/z def test_coercion(int a, float b, double c, float complex d, double complex e): """ -- 2.26.2