Commit ab0acc7a authored by Robert Bradshaw's avatar Robert Bradshaw

Fix complex zero division testing.

parent 7dd76b30
...@@ -5536,6 +5536,7 @@ class CoercionNode(ExprNode): ...@@ -5536,6 +5536,7 @@ class CoercionNode(ExprNode):
# arg ExprNode node being coerced # arg ExprNode node being coerced
subexprs = ['arg'] subexprs = ['arg']
constant_result = not_a_constant
def __init__(self, arg): def __init__(self, arg):
self.pos = arg.pos self.pos = arg.pos
......
#cdef extern from "complex.h":
# pass
cimport cython cimport cython
def test_object_conversion(o): def test_object_conversion(o):
...@@ -23,21 +20,20 @@ def test_arithmetic(double complex z, double complex w): ...@@ -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)) ((6+12j), (-6-12j), (6+15j), (6+9j), (-36+18j), (4-2j))
>>> test_arithmetic(5-10j, 3+4j) >>> test_arithmetic(5-10j, 3+4j)
((5-10j), (-5+10j), (8-6j), (2-14j), (55-10j), (-1-2j)) ((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 return +z, -z, z+w, z-w, z*w, z/w
## XXX this is not working @cython.cdivision(False)
## @cython.cdivision(False) def test_div_by_zero(double complex z):
## def test_div_by_zero(double complex z): """
## return 1/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): def test_coercion(int a, float b, double c, float complex d, double complex e):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment