https://github.com/python/cpython/commit/a8460a285a9455fe0ab0ccf484e6f965a7cacf8e
commit: a8460a285a9455fe0ab0ccf484e6f965a7cacf8e
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2025-09-02T17:04:13Z
summary:

[3.13] gh-136599: Add tests for long_hash (GH-138335) (#138391)

gh-136599: Add tests for long_hash (GH-138335)
(cherry picked from commit 2d3711dc06657e072a83b580636cbb0009658636)

Co-authored-by: Pieter Eendebak <[email protected]>
Co-authored-by: Sergey B Kirpichev <[email protected]>

files:
M Lib/test/test_long.py

diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 41b973da2c7df0..b247f3322c2b08 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -1642,5 +1642,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()

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to