Files
micropython/tests/basics/int_big_to_small_int29.py
Jeff Epler f6dcf35d5c tests/basics/int_big_to_small.py: Bifurcate test using small-int-max.
Different results are needed for different integer sizes.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-28 23:23:11 +10:00

23 lines
472 B
Python

try:
import micropython
micropython.heap_lock
except:
print("SKIP")
raise SystemExit
# All less than small int max.
for d in (0, 27, 1<<28, -1861, -(1<<28)):
i = 1<<70
print(i)
j = (1<<70) + d
print(j)
# k should now be a small int.
k = j - i
print(k)
# Now verify that working with k doesn't allocate (i.e. it's a small int).
micropython.heap_lock()
print(k + 20)
print(k // 20)
micropython.heap_unlock()