tests/basics: Add tests for edge cases of nan-box's 47-bit small int.
This commit is contained in:
parent
dd48ccb1e3
commit
7b7bbd0ee7
|
@ -7,3 +7,7 @@ print(abs(-123456789012345678901234567890))
|
||||||
# edge cases for 32 and 64 bit archs (small int overflow when negating)
|
# edge cases for 32 and 64 bit archs (small int overflow when negating)
|
||||||
print(abs(-0x3fffffff - 1))
|
print(abs(-0x3fffffff - 1))
|
||||||
print(abs(-0x3fffffffffffffff - 1))
|
print(abs(-0x3fffffffffffffff - 1))
|
||||||
|
|
||||||
|
# edge case for nan-boxing with 47-bit small int
|
||||||
|
i = -0x3fffffffffff
|
||||||
|
print(abs(i - 1))
|
||||||
|
|
|
@ -90,6 +90,11 @@ x = 1073741823 # small
|
||||||
x = -1073741823 # small
|
x = -1073741823 # small
|
||||||
x = 1073741824 # big
|
x = 1073741824 # big
|
||||||
x = -1073741824 # big
|
x = -1073741824 # big
|
||||||
|
# for nan-boxing with 47-bit small ints
|
||||||
|
print(int('0x3fffffffffff', 16)) # small
|
||||||
|
print(int('-0x3fffffffffff', 16)) # small
|
||||||
|
print(int('0x400000000000', 16)) # big
|
||||||
|
print(int('-0x400000000000', 16)) # big
|
||||||
# for 64 bit archs
|
# for 64 bit archs
|
||||||
x = 4611686018427387903 # small
|
x = 4611686018427387903 # small
|
||||||
x = -4611686018427387903 # small
|
x = -4611686018427387903 # small
|
||||||
|
|
|
@ -5,6 +5,11 @@ i = 0x3fffffff
|
||||||
print(i + i)
|
print(i + i)
|
||||||
print(-i + -i)
|
print(-i + -i)
|
||||||
|
|
||||||
|
# 47-bit overflow
|
||||||
|
i = 0x3fffffffffff
|
||||||
|
print(i + i)
|
||||||
|
print(-i + -i)
|
||||||
|
|
||||||
# 63-bit overflow
|
# 63-bit overflow
|
||||||
i = 0x3fffffffffffffff
|
i = 0x3fffffffffffffff
|
||||||
print(i + i)
|
print(i + i)
|
||||||
|
|
Loading…
Reference in New Issue