summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-10-29 12:25:07 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-10-29 12:25:07 (GMT)
commit9050bb28f2d73a1be8d568aea2b2eb9f53b90468 (patch)
treefe9d699d7baf2f5f41971079c117888e097f5718 /Lib/test/test_decimal.py
parent00de1bdcfcc9b5d4555c77796c0c8e93944bfb7d (diff)
downloadcpython-9050bb28f2d73a1be8d568aea2b2eb9f53b90468.zip
cpython-9050bb28f2d73a1be8d568aea2b2eb9f53b90468.tar.gz
cpython-9050bb28f2d73a1be8d568aea2b2eb9f53b90468.tar.bz2
Merged revisions 75947 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r75947 | mark.dickinson | 2009-10-29 12:23:02 +0000 (Thu, 29 Oct 2009) | 20 lines Merged revisions 75943-75945 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line Fix duplicate test numbers in extra.decTest ........ r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. ........ r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. ........ ................
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 4bf9d3a..bf7d3b2 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1529,6 +1529,53 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(str(Decimal(0).sqrt()),
str(c.sqrt(Decimal(0))))
+ def test_conversions_from_int(self):
+ # Check that methods taking a second Decimal argument will
+ # always accept an integer in place of a Decimal.
+ self.assertEqual(Decimal(4).compare(3),
+ Decimal(4).compare(Decimal(3)))
+ self.assertEqual(Decimal(4).compare_signal(3),
+ Decimal(4).compare_signal(Decimal(3)))
+ self.assertEqual(Decimal(4).compare_total(3),
+ Decimal(4).compare_total(Decimal(3)))
+ self.assertEqual(Decimal(4).compare_total_mag(3),
+ Decimal(4).compare_total_mag(Decimal(3)))
+ self.assertEqual(Decimal(10101).logical_and(1001),
+ Decimal(10101).logical_and(Decimal(1001)))
+ self.assertEqual(Decimal(10101).logical_or(1001),
+ Decimal(10101).logical_or(Decimal(1001)))
+ self.assertEqual(Decimal(10101).logical_xor(1001),
+ Decimal(10101).logical_xor(Decimal(1001)))
+ self.assertEqual(Decimal(567).max(123),
+ Decimal(567).max(Decimal(123)))
+ self.assertEqual(Decimal(567).max_mag(123),
+ Decimal(567).max_mag(Decimal(123)))
+ self.assertEqual(Decimal(567).min(123),
+ Decimal(567).min(Decimal(123)))
+ self.assertEqual(Decimal(567).min_mag(123),
+ Decimal(567).min_mag(Decimal(123)))
+ self.assertEqual(Decimal(567).next_toward(123),
+ Decimal(567).next_toward(Decimal(123)))
+ self.assertEqual(Decimal(1234).quantize(100),
+ Decimal(1234).quantize(Decimal(100)))
+ self.assertEqual(Decimal(768).remainder_near(1234),
+ Decimal(768).remainder_near(Decimal(1234)))
+ self.assertEqual(Decimal(123).rotate(1),
+ Decimal(123).rotate(Decimal(1)))
+ self.assertEqual(Decimal(1234).same_quantum(1000),
+ Decimal(1234).same_quantum(Decimal(1000)))
+ self.assertEqual(Decimal('9.123').scaleb(-100),
+ Decimal('9.123').scaleb(Decimal(-100)))
+ self.assertEqual(Decimal(456).shift(-1),
+ Decimal(456).shift(Decimal(-1)))
+
+ self.assertEqual(Decimal(-12).fma(Decimal(45), 67),
+ Decimal(-12).fma(Decimal(45), Decimal(67)))
+ self.assertEqual(Decimal(-12).fma(45, 67),
+ Decimal(-12).fma(Decimal(45), Decimal(67)))
+ self.assertEqual(Decimal(-12).fma(45, Decimal(67)),
+ Decimal(-12).fma(Decimal(45), Decimal(67)))
+
class DecimalPythonAPItests(unittest.TestCase):