diff options
author | Thomas Wouters <thomas@python.org> | 2007-09-20 18:22:40 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2007-09-20 18:22:40 (GMT) |
commit | 8ce81f767a48e9e645c523137c7f83e49f79f986 (patch) | |
tree | 68e5fa3f61af5f75d43de717a0c997db77dd2910 /Lib/test/test_decimal.py | |
parent | 7ce29ca41cd2c41ac7a5981d182f8db25c2af977 (diff) | |
download | cpython-8ce81f767a48e9e645c523137c7f83e49f79f986.zip cpython-8ce81f767a48e9e645c523137c7f83e49f79f986.tar.gz cpython-8ce81f767a48e9e645c523137c7f83e49f79f986.tar.bz2 |
Merged revisions 58211-58220 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58211 | facundo.batista | 2007-09-19 19:53:25 +0200 (Wed, 19 Sep 2007) | 4 lines
Issue #1772851. Optimization of __hash__ to behave better for big big
numbers.
........
r58216 | raymond.hettinger | 2007-09-20 05:03:43 +0200 (Thu, 20 Sep 2007) | 1 line
Fit nits
........
r58217 | georg.brandl | 2007-09-20 10:44:59 +0200 (Thu, 20 Sep 2007) | 2 lines
alternate -> alternative.
........
r58218 | georg.brandl | 2007-09-20 18:06:07 +0200 (Thu, 20 Sep 2007) | 2 lines
Patch #1541463: optimize performance of cgi.FieldStorage operations.
........
r58219 | georg.brandl | 2007-09-20 18:45:27 +0200 (Thu, 20 Sep 2007) | 2 lines
#1176: document that string methods don't take keyword args.
........
r58220 | thomas.wouters | 2007-09-20 19:35:10 +0200 (Thu, 20 Sep 2007) | 4 lines
Try harder to stay within the 79-column limit. There's still two places that go (way) over, but those are harder to fix without suffering in readability.
........
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 41d1dd5..513ba16 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -901,6 +901,38 @@ class DecimalUsabilityTest(unittest.TestCase): def test_hash_method(self): #just that it's hashable hash(Decimal(23)) + + test_values = [Decimal(sign*(2**m + n)) + for m in [0, 14, 15, 16, 17, 30, 31, + 32, 33, 62, 63, 64, 65, 66] + for n in range(-10, 10) + for sign in [-1, 1]] + test_values.extend([ + Decimal("-0"), # zeros + Decimal("0.00"), + Decimal("-0.000"), + Decimal("0E10"), + Decimal("-0E12"), + Decimal("10.0"), # negative exponent + Decimal("-23.00000"), + Decimal("1230E100"), # positive exponent + Decimal("-4.5678E50"), + # a value for which hash(n) != hash(n % (2**64-1)) + # in Python pre-2.6 + Decimal(2**64 + 2**32 - 1), + # selection of values which fail with the old (before + # version 2.6) long.__hash__ + Decimal("1.634E100"), + Decimal("90.697E100"), + Decimal("188.83E100"), + Decimal("1652.9E100"), + Decimal("56531E100"), + ]) + + # check that hash(d) == hash(int(d)) for integral values + for value in test_values: + self.assertEqual(hash(value), hash(int(value))) + #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) self.assertRaises(TypeError, hash, Decimal('NaN')) |