Skip to content

Commit d3f7c80

Browse files
committed
Add some test coverage
Some tests are failing!
1 parent 8951088 commit d3f7c80

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lib/test/test_complex.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,18 +669,22 @@ def check(z, x, y):
669669
check(complex("1"), 1.0, 0.0)
670670
check(complex("1j"), 0.0, 1.0)
671671
check(complex("-1"), -1.0, 0.0)
672+
check(complex("\N{MINUS SIGN}1"), -1.0, 0.0)
672673
check(complex("+1"), 1.0, 0.0)
673674
check(complex("1+2j"), 1.0, 2.0)
674675
check(complex("(1+2j)"), 1.0, 2.0)
675676
check(complex("(1.5+4.25j)"), 1.5, 4.25)
676677
check(complex("4.25+1J"), 4.25, 1.0)
677678
check(complex(" ( +4.25-6J )"), 4.25, -6.0)
679+
check(complex(" ( +4.25\N{MINUS SIGN}6J )"), 4.25, -6.0)
678680
check(complex(" ( +4.25-J )"), 4.25, -1.0)
681+
check(complex(" ( +4.25\N{MINUS SIGN}J )"), 4.25, -1.0)
679682
check(complex(" ( +4.25+j )"), 4.25, 1.0)
680683
check(complex("J"), 0.0, 1.0)
681684
check(complex("( j )"), 0.0, 1.0)
682685
check(complex("+J"), 0.0, 1.0)
683686
check(complex("( -j)"), 0.0, -1.0)
687+
check(complex("( \N{MINUS SIGN}j)"), 0.0, -1.0)
684688
check(complex('1-1j'), 1.0, -1.0)
685689
check(complex('1J'), 0.0, 1.0)
686690

@@ -690,6 +694,7 @@ def check(z, x, y):
690694
check(complex('-1e-500+1e-500j'), -0.0, 0.0)
691695
check(complex('1e-500-1e-500j'), 0.0, -0.0)
692696
check(complex('-1e-500-1e-500j'), -0.0, -0.0)
697+
check(complex('\N{MINUS SIGN}1e\N{MINUS SIGN}500\N{MINUS SIGN}1e\N{MINUS SIGN}500j'), -0.0, -0.0)
693698

694699
# SF bug 543840: complex(string) accepts strings with \0
695700
# Fixed in 2.3.
@@ -700,6 +705,8 @@ def check(z, x, y):
700705
self.assertRaises(ValueError, complex, "1+")
701706
self.assertRaises(ValueError, complex, "1+1j+1j")
702707
self.assertRaises(ValueError, complex, "--")
708+
self.assertRaises(ValueError, complex, "-\N{MINUS SIGN}")
709+
self.assertRaises(ValueError, complex, "\N{MINUS SIGN}\N{MINUS SIGN}")
703710
self.assertRaises(ValueError, complex, "(1+2j")
704711
self.assertRaises(ValueError, complex, "1+2j)")
705712
self.assertRaises(ValueError, complex, "1+(2j)")
@@ -726,7 +733,9 @@ def test_constructor_negative_nans_from_string(self):
726733
self.assertEqual(copysign(1., complex("-nan").real), -1.)
727734
self.assertEqual(copysign(1., complex("-nanj").imag), -1.)
728735
self.assertEqual(copysign(1., complex("-nan-nanj").real), -1.)
736+
self.assertEqual(copysign(1., complex("-nan\N{MINUS SIGN}nanj").real), -1.)
729737
self.assertEqual(copysign(1., complex("-nan-nanj").imag), -1.)
738+
self.assertEqual(copysign(1., complex("\N{MINUS SIGN}nan\N{MINUS SIGN}nanj").imag), -1.)
730739

731740
def test_underscores(self):
732741
# check underscores

Lib/test/test_float.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ def test_float(self):
6868
self.assertRaises(ValueError, float, " +0x3.p-1 ")
6969
self.assertRaises(ValueError, float, "++3.14")
7070
self.assertRaises(ValueError, float, "+-3.14")
71+
self.assertRaises(ValueError, float, "+\N{MINUS SIGN}3.14")
7172
self.assertRaises(ValueError, float, "-+3.14")
7273
self.assertRaises(ValueError, float, "--3.14")
74+
self.assertRaises(ValueError, float, "-\N{MINUS SIGN}3.14")
75+
self.assertRaises(ValueError, float, "\N{MINUS SIGN}\N{MINUS SIGN}3.14")
7376
self.assertRaises(ValueError, float, ".nan")
7477
self.assertRaises(ValueError, float, "+.inf")
7578
self.assertRaises(ValueError, float, ".")
7679
self.assertRaises(ValueError, float, "-.")
80+
self.assertRaises(ValueError, float, "\N{MINUS SIGN}.")
7781
self.assertRaises(TypeError, float, {})
7882
self.assertRaisesRegex(TypeError, "not 'dict'", float, {})
7983
# Lone surrogate

Lib/test/test_long.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_long(self):
328328
('1' + '0'*100, 10**100)
329329
]
330330
for s, v in LL:
331-
for sign in "", "+", "-":
331+
for sign in "", "+", "-", "\N{MINUS SIGN}":
332332
for prefix in "", " ", "\t", " \t\t ":
333333
ss = prefix + sign + s
334334
vv = v
@@ -360,9 +360,11 @@ def test_long(self):
360360
self.assertEqual(int('0', 0), 0)
361361
self.assertEqual(int('+0', 0), 0)
362362
self.assertEqual(int('-0', 0), 0)
363+
self.assertEqual(int('\N{MINUS SIGN}0', 0), 0)
363364
self.assertEqual(int('00', 0), 0)
364365
self.assertRaises(ValueError, int, '08', 0)
365366
self.assertRaises(ValueError, int, '-012395', 0)
367+
self.assertRaises(ValueError, int, '\N{MINUS SIGN}012395', 0)
366368

367369
# invalid bases
368370
invalid_bases = [-909,

0 commit comments

Comments
 (0)