Browse Source

tests/basics: Add tests for edge cases of nan-box's 47-bit small int.

pull/3696/merge
Damien George 7 years ago
parent
commit
7b7bbd0ee7
  1. 4
      tests/basics/builtin_abs_intbig.py
  2. 5
      tests/basics/int_big1.py
  3. 5
      tests/basics/int_big_add.py

4
tests/basics/builtin_abs_intbig.py

@ -7,3 +7,7 @@ print(abs(-123456789012345678901234567890))
# edge cases for 32 and 64 bit archs (small int overflow when negating)
print(abs(-0x3fffffff - 1))
print(abs(-0x3fffffffffffffff - 1))
# edge case for nan-boxing with 47-bit small int
i = -0x3fffffffffff
print(abs(i - 1))

5
tests/basics/int_big1.py

@ -90,6 +90,11 @@ x = 1073741823 # small
x = -1073741823 # small
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
x = 4611686018427387903 # small
x = -4611686018427387903 # small

5
tests/basics/int_big_add.py

@ -5,6 +5,11 @@ i = 0x3fffffff
print(i + i)
print(-i + -i)
# 47-bit overflow
i = 0x3fffffffffff
print(i + i)
print(-i + -i)
# 63-bit overflow
i = 0x3fffffffffffffff
print(i + i)

Loading…
Cancel
Save