summaryrefslogtreecommitdiff
path: root/tests/basics/int_big_to_small.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/int_big_to_small.py')
-rw-r--r--tests/basics/int_big_to_small.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/basics/int_big_to_small.py b/tests/basics/int_big_to_small.py
new file mode 100644
index 000000000..64280d0c6
--- /dev/null
+++ b/tests/basics/int_big_to_small.py
@@ -0,0 +1,22 @@
+try:
+ import micropython
+ micropython.heap_lock
+except:
+ print("SKIP")
+ raise SystemExit
+
+# All less than small int max.
+for d in (0, 27, 1<<29, -1861, -(1<<29)):
+ 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()