summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2001-12-29 01:02:21 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2001-12-29 01:02:21 (GMT)
commitfc37af85bf39f3f7fdd4f99cdc238930d55dd78f (patch)
tree075f7788f595f903f6ede56f9242696267bf642b /Lib
parent32f41536cbcae7ebcec748a66165b210cfe88fd7 (diff)
downloadcpython-fc37af85bf39f3f7fdd4f99cdc238930d55dd78f.zip
cpython-fc37af85bf39f3f7fdd4f99cdc238930d55dd78f.tar.gz
cpython-fc37af85bf39f3f7fdd4f99cdc238930d55dd78f.tar.bz2
SF Patch #494873 add tests for complex numbers including calls to int()/long()
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_complex.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index f16fb3b..65fccc3 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -56,6 +56,27 @@ for i in range(100):
test_div(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:
z = 1.0 / (0+0j)
except ZeroDivisionError: