summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index 42dc3cf..fbed4f2 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -4,6 +4,8 @@ from test import test_support
from random import random
from math import atan2
+INF = float("inf")
+NAN = float("nan")
# These tests ensure that complex math does the right thing
class ComplexTest(unittest.TestCase):
@@ -316,6 +318,18 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(-6j,complex(repr(-6j)))
self.assertEqual(6j,complex(repr(6j)))
+ self.assertEqual(repr(complex(1., INF)), "(1+inf*j)")
+ self.assertEqual(repr(complex(1., -INF)), "(1-inf*j)")
+ self.assertEqual(repr(complex(INF, 1)), "(inf+1j)")
+ self.assertEqual(repr(complex(-INF, INF)), "(-inf+inf*j)")
+ self.assertEqual(repr(complex(NAN, 1)), "(nan+1j)")
+ self.assertEqual(repr(complex(1, NAN)), "(1+nan*j)")
+ self.assertEqual(repr(complex(NAN, NAN)), "(nan+nan*j)")
+
+ self.assertEqual(repr(complex(0, INF)), "inf*j")
+ self.assertEqual(repr(complex(0, -INF)), "-inf*j")
+ self.assertEqual(repr(complex(0, NAN)), "nan*j")
+
def test_neg(self):
self.assertEqual(-(1+6j), -1-6j)