mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.14] gh-136599: Add tests for long_hash (GH-138335) (#138390)
gh-136599: Add tests for long_hash (GH-138335)
(cherry picked from commit 2d3711dc06)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
a963843f43
commit
38cd031111
1 changed files with 16 additions and 0 deletions
|
|
@ -1693,5 +1693,21 @@ class MyInt(int):
|
|||
# GH-117195 -- This shouldn't crash
|
||||
object.__sizeof__(1)
|
||||
|
||||
def test_hash(self):
|
||||
# gh-136599
|
||||
self.assertEqual(hash(-1), -2)
|
||||
self.assertEqual(hash(0), 0)
|
||||
self.assertEqual(hash(10), 10)
|
||||
|
||||
self.assertEqual(hash(sys.hash_info.modulus - 2), sys.hash_info.modulus - 2)
|
||||
self.assertEqual(hash(sys.hash_info.modulus - 1), sys.hash_info.modulus - 1)
|
||||
self.assertEqual(hash(sys.hash_info.modulus), 0)
|
||||
self.assertEqual(hash(sys.hash_info.modulus + 1), 1)
|
||||
|
||||
self.assertEqual(hash(-sys.hash_info.modulus - 2), -2)
|
||||
self.assertEqual(hash(-sys.hash_info.modulus - 1), -2)
|
||||
self.assertEqual(hash(-sys.hash_info.modulus), 0)
|
||||
self.assertEqual(hash(-sys.hash_info.modulus + 1), -sys.hash_info.modulus + 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue