]> granicus.if.org Git - python/commitdiff
SF Patch #494873 add tests for complex numbers including calls to int()/long()
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Dec 2001 01:02:21 +0000 (01:02 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Dec 2001 01:02:21 +0000 (01:02 +0000)
Lib/test/test_complex.py

index f16fb3bf2e7ffdbd084f225e662bc2a7e501720b..65fccc39cd5caea79ceb5e483cc62c9c8acd64b4 100644 (file)
@@ -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: