mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
SF Patch #494873 add tests for complex numbers including calls to int()/long()
This commit is contained in:
parent
32f41536cb
commit
fc37af85bf
1 changed files with 21 additions and 0 deletions
|
@ -56,6 +56,27 @@ for i in range(100):
|
||||||
test_div(complex(random(), random()),
|
test_div(complex(random(), random()),
|
||||||
complex(random(), random()))
|
complex(random(), random()))
|
||||||
|
|
||||||
|
for i in range(100):
|
||||||
|
if not complex(random() + 1e-6, random() + 1e-6):
|
||||||
|
raise TestFailed("complex(random(), random()) should be true")
|
||||||
|
|
||||||
|
if complex(0.0, 0.0):
|
||||||
|
raise TestFailed("complex(0.0, 0.0) should be false")
|
||||||
|
|
||||||
|
try:
|
||||||
|
print int(5+3j)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise TestFailed("int(complex()) didn't raise TypeError")
|
||||||
|
|
||||||
|
try:
|
||||||
|
print float(5+3j)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise TestFailed("float(complex()) didn't raise TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
z = 1.0 / (0+0j)
|
z = 1.0 / (0+0j)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue