summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-04-24 13:25:20 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-04-24 13:25:20 (GMT)
commit6649fa42f87397c701e528f77374d21bf00d2ca3 (patch)
tree144e5668fb52d67bdee4a1bab1763f4d92d5f0f9 /Lib/test/test_complex.py
parentc00b5ef06ee8ac9bc2bc0f37abf68804866a0ce7 (diff)
downloadcpython-6649fa42f87397c701e528f77374d21bf00d2ca3.zip
cpython-6649fa42f87397c701e528f77374d21bf00d2ca3.tar.gz
cpython-6649fa42f87397c701e528f77374d21bf00d2ca3.tar.bz2
Make sure that complex parsing code and corresponding tests
match for 2.7 and 3.1, and that 3.1 continues to accept complex('j') and complex('4-j')
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index 836360a..d029d86 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -227,6 +227,15 @@ class ComplexTest(unittest.TestCase):
self.assertAlmostEqual(complex("(1.3+2.2j)"), 1.3+2.2j)
self.assertAlmostEqual(complex("3.14+1J"), 3.14+1j)
self.assertAlmostEqual(complex(" ( +3.14-6J )"), 3.14-6j)
+ self.assertAlmostEqual(complex(" ( +3.14-J )"), 3.14-1j)
+ self.assertAlmostEqual(complex(" ( +3.14+j )"), 3.14+1j)
+ self.assertAlmostEqual(complex("J"), 1j)
+ self.assertAlmostEqual(complex("( j )"), 1j)
+ self.assertAlmostEqual(complex("+J"), 1j)
+ self.assertAlmostEqual(complex("( -j)"), -1j)
+ self.assertAlmostEqual(complex('1e-500'), 0.0 + 0.0j)
+ self.assertAlmostEqual(complex('-1e-500j'), 0.0 - 0.0j)
+ self.assertAlmostEqual(complex('-1e-500+1e-500j'), -0.0 + 0.0j)
class complex2(complex): pass
self.assertAlmostEqual(complex(complex2(1+1j)), 1+1j)
@@ -277,11 +286,14 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "(1+2j)123")
self.assertRaises(ValueError, complex, "1"*500)
self.assertRaises(ValueError, complex, "x")
- self.assertRaises(ValueError, complex, "J")
self.assertRaises(ValueError, complex, "1j+2")
self.assertRaises(ValueError, complex, "1e1ej")
self.assertRaises(ValueError, complex, "1e++1ej")
self.assertRaises(ValueError, complex, ")1+2j(")
+ # the following three are accepted by Python 2.6
+ self.assertRaises(ValueError, complex, "1..1j")
+ self.assertRaises(ValueError, complex, "1.11.1j")
+ self.assertRaises(ValueError, complex, "1e1.1j")
class EvilExc(Exception):
pass