summaryrefslogtreecommitdiff
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-07-05 18:49:38 +0000
committerRaymond Hettinger <python@rcn.com>2004-07-05 18:49:38 +0000
commitb17cf443afe7912bd430537edaab2b93a04efa6a (patch)
treecbe508ac63ba9f9e6809afe9ba0ceaf12d35313b /Lib/test/test_decimal.py
parent57d26b7ff436bf5d775f9275093dbe4b55484d42 (diff)
downloadcpython-b17cf443afe7912bd430537edaab2b93a04efa6a.tar.gz
Test the logic for int(d).
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 7bfb13c385..51b3528023 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -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):