mirror of
https://github.com/python/cpython.git
synced 2024-12-24 09:15:04 +08:00
Test the logic for int(d).
This commit is contained in:
parent
ca3cc2fe21
commit
5548be2653
@ -1058,6 +1058,16 @@ class DecimalPythonAPItests(unittest.TestCase):
|
||||
e = pickle.loads(p)
|
||||
self.assertEqual(d, e)
|
||||
|
||||
def test_int(self):
|
||||
data = '1.0 1.1 1.9 2.0 0.0 -1.0 -1.1 -1.9 -2.0'.split()
|
||||
for s in data:
|
||||
# should work the same as for floats
|
||||
self.assertEqual(int(Decimal(s)), int(float(s)))
|
||||
# should work the same as ROUND_DOWN
|
||||
d = Decimal(s)
|
||||
r = Context(prec=1, rounding=ROUND_DOWN).create_decimal(s)
|
||||
self.assertEqual(Decimal(int(d)), r)
|
||||
|
||||
class ContextAPItests(unittest.TestCase):
|
||||
|
||||
def test_pickle(self):
|
||||
|
Loading…
Reference in New Issue
Block a user