8000 add pylong_import() tests on normalize + singletons · python/cpython@294f53a · GitHub
[go: up one dir, main page]

Skip to content

Commit 294f53a

Browse files
committed
add pylong_import() tests on normalize + singletons
1 parent b67b73a commit 294f53a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_capi/test_long.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,13 @@ def test_long_import(self):
787787
self.assertEqual(pylong_import(0, [1, 2, 3]),
788788
shift**2 * 3 + shift * 2 + 1)
789789

790+
# normalize
791+
self.assertEqual(pylong_import(0, [123, 0, 0]), 123)
792+
793+
# test singletons + normalize
794+
for num in (-2, 0, 1, 5, 42, 100):
795+
self.assertIs(pylong_import(bool(num < 0), [abs(num), 0]), num)
796+
790797
# round trip: Python int -> export -> Python int
791798
pylong_export = _testcapi.pylong_export
792799
numbers = [*range(0, 10), 12345, 0xdeadbeef, 2**100, 2**100-1]

0 commit comments

Comments
 (0)
0