Skip to content

Commit 5c2cc82

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 5ec6d56 commit 5c2cc82

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
@@ -1693,5 +1693,21 @@ class MyInt(int):
16931693
# GH-117195 -- This shouldn't crash
16941694
object.__sizeof__(1)
16951695

1696+
def test_hash(self):
1697+
# gh-136599
1698+
self.assertEqual(hash(-1), -2)
1699+
self.assertEqual(hash(0), 0)
1700+
self.assertEqual(hash(10), 10)
1701+
1702+
self.assertEqual(hash(sys.hash_info.modulus - 2), sys.hash_info.modulus - 2)
1703+
self.assertEqual(hash(sys.hash_info.modulus - 1), sys.hash_info.modulus - 1)
1704+
self.assertEqual(hash(sys.hash_info.modulus), 0)
1705+
self.assertEqual(hash(sys.hash_info.modulus + 1), 1)
1706+
1707+
self.assertEqual(hash(-sys.hash_info.modulus - 2), -2)
1708+
self.assertEqual(hash(-sys.hash_info.modulus - 1), -2)
1709+
self.assertEqual(hash(-sys.hash_info.modulus), 0)
1710+
self.assertEqual(hash(-sys.hash_info.modulus + 1), -sys.hash_info.modulus + 1)
1711+
16961712
if __name__ == "__main__":
16971713
unittest.main()

0 commit comments

Comments
 (0)