Skip to content

Commit 7b7bbd0

Browse files
committed
tests/basics: Add tests for edge cases of nan-box's 47-bit small int.
1 parent dd48ccb commit 7b7bbd0

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

tests/basics/builtin_abs_intbig.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
# edge cases for 32 and 64 bit archs (small int overflow when negating)
88
print(abs(-0x3fffffff - 1))
99
print(abs(-0x3fffffffffffffff - 1))
10+
11+
# edge case for nan-boxing with 47-bit small int
12+
i = -0x3fffffffffff
13+
print(abs(i - 1))

tests/basics/int_big1.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090
x = -1073741823 # small
9191
x = 1073741824 # big
9292
x = -1073741824 # big
93+
# for nan-boxing with 47-bit small ints
94+
print(int('0x3fffffffffff', 16)) # small
95+
print(int('-0x3fffffffffff', 16)) # small
96+
print(int('0x400000000000', 16)) # big
97+
print(int('-0x400000000000', 16)) # big
9398
# for 64 bit archs
9499
x = 4611686018427387903 # small
95100
x = -4611686018427387903 # small

tests/basics/int_big_add.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
print(i + i)
66
print(-i + -i)
77

8+
# 47-bit overflow
9+
i = 0x3fffffffffff
10+
print(i + i)
11+
print(-i + -i)
12+
813
# 63-bit overflow
914
i = 0x3fffffffffffffff
1015
print(i + i)

0 commit comments

Comments
 (0)