mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108)
This commit is contained in:
parent
1a4d9ffa1a
commit
bdbad71b9d
15 changed files with 181 additions and 23 deletions
|
@ -457,6 +457,8 @@ class Float_TestCase(unittest.TestCase):
|
|||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(getargs_f(BadFloat2()), 4.25)
|
||||
self.assertEqual(getargs_f(BadFloat3(7.5)), 7.5)
|
||||
self.assertEqual(getargs_f(Index()), 99.0)
|
||||
self.assertRaises(TypeError, getargs_f, Int())
|
||||
|
||||
for x in (FLT_MIN, -FLT_MIN, FLT_MAX, -FLT_MAX, INF, -INF):
|
||||
self.assertEqual(getargs_f(x), x)
|
||||
|
@ -489,6 +491,8 @@ class Float_TestCase(unittest.TestCase):
|
|||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(getargs_d(BadFloat2()), 4.25)
|
||||
self.assertEqual(getargs_d(BadFloat3(7.5)), 7.5)
|
||||
self.assertEqual(getargs_d(Index()), 99.0)
|
||||
self.assertRaises(TypeError, getargs_d, Int())
|
||||
|
||||
for x in (DBL_MIN, -DBL_MIN, DBL_MAX, -DBL_MAX, INF, -INF):
|
||||
self.assertEqual(getargs_d(x), x)
|
||||
|
@ -511,6 +515,8 @@ class Float_TestCase(unittest.TestCase):
|
|||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(getargs_D(BadComplex2()), 4.25+0.5j)
|
||||
self.assertEqual(getargs_D(BadComplex3(7.5+0.25j)), 7.5+0.25j)
|
||||
self.assertEqual(getargs_D(Index()), 99.0+0j)
|
||||
self.assertRaises(TypeError, getargs_D, Int())
|
||||
|
||||
for x in (DBL_MIN, -DBL_MIN, DBL_MAX, -DBL_MAX, INF, -INF):
|
||||
c = complex(x, 1.0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue