Skip to content

Commit 4932307

Browse files
eendebakptskirpichev
authored andcommitted
pythongh-136599: Add tests for long_hash (pythonGH-138335)
(cherry picked from commit 2d3711d) Co-authored-by: Pieter Eendebak <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
1 parent f88bf2c commit 4932307

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_long.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,5 +1642,21 @@ class MyInt(int):
16421642
# GH-117195 -- This shouldn't crash
16431643
object.__sizeof__(1)
16441644

1645+
def test_hash(self):
1646+
# gh-136599
1647+
self.assertEqual(hash(-1), -2)
1648+
self.assertEqual(hash(0), 0)
1649+
self.assertEqual(hash(10), 10)
1650+
1651+
self.assertEqual(hash(sys.hash_info.modulus - 2), sys.hash_info.modulus - 2)
1652+
self.assertEqual(hash(sys.hash_info.modulus - 1), sys.hash_info.modulus - 1)
1653+
self.assertEqual(hash(sys.hash_info.modulus), 0)
1654+
self.assertEqual(hash(sys.hash_info.modulus + 1), 1)
1655+
1656+
self.assertEqual(hash(-sys.hash_info.modulus - 2), -2)
1657+
self.assertEqual(hash(-sys.hash_info.modulus - 1), -2)
1658+
self.assertEqual(hash(-sys.hash_info.modulus), 0)
1659+
self.assertEqual(hash(-sys.hash_info.modulus + 1), -sys.hash_info.modulus + 1)
1660+
16451661
if __name__ == "__main__":
16461662
unittest.main()

0 commit comments

Comments
 (0)