summaryrefslogtreecommitdiff
path: root/tests/micropython
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-04-11 23:34:37 +1000
committerDamien George <damien@micropython.org>2022-04-15 00:17:02 +1000
commit865b61dac205fe10150e8c4a38411470b4eb82f4 (patch)
treefb35498c8e0d00a457b789779ab2224ef20a8d78 /tests/micropython
parent07f526067e207f23529b4f2234baffd74ce1f35c (diff)
tests/micropython: Add tests that const tuples don't use the heap.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython')
-rw-r--r--tests/micropython/heapalloc.py8
-rw-r--r--tests/micropython/heapalloc.py.exp4
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/micropython/heapalloc.py b/tests/micropython/heapalloc.py
index 99f157105..e19f8d025 100644
--- a/tests/micropython/heapalloc.py
+++ b/tests/micropython/heapalloc.py
@@ -33,6 +33,10 @@ def f3(a, b, c, d):
print(x1, x3, x5, x7, x2 + x4 + x6 + x8)
+def f4():
+ return True, b"bytes", ()
+
+
global_var = 1
@@ -45,7 +49,11 @@ def test():
f1(a=i) # keyword arguments
f2(i) # default arg (second one)
f2(i, i) # 2 args
+ f1((1, "two", (b"three",))) # use a constant tuple
f3(1, 2, 3, 4) # function with lots of local state
+ for i in 1, "two": # iterate over constant tuple
+ print(i)
+ print(f4()) # returns a constant tuple
# call test() with heap allocation disabled
diff --git a/tests/micropython/heapalloc.py.exp b/tests/micropython/heapalloc.py.exp
index c8cffe183..b8580edc6 100644
--- a/tests/micropython/heapalloc.py.exp
+++ b/tests/micropython/heapalloc.py.exp
@@ -8,4 +8,8 @@
1
1 2
1 1
+(1, 'two', (b'three',))
1 2 3 4 10
+1
+two
+(True, b'bytes', ())