Skip to content

Commit 865b61d

Browse files
committed
tests/micropython: Add tests that const tuples don't use the heap.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 07f5260 commit 865b61d

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/micropython/heapalloc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def f3(a, b, c, d):
3333
print(x1, x3, x5, x7, x2 + x4 + x6 + x8)
3434

3535

36+
def f4():
37+
return True, b"bytes", ()
38+
39+
3640
global_var = 1
3741

3842

@@ -45,7 +49,11 @@ def test():
4549
f1(a=i) # keyword arguments
4650
f2(i) # default arg (second one)
4751
f2(i, i) # 2 args
52+
f1((1, "two", (b"three",))) # use a constant tuple
4853
f3(1, 2, 3, 4) # function with lots of local state
54+
for i in 1, "two": # iterate over constant tuple
55+
print(i)
56+
print(f4()) # returns a constant tuple
4957

5058

5159
# call test() with heap allocation disabled

tests/micropython/heapalloc.py.exp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
1
99
1 2
1010
1 1
11+
(1, 'two', (b'three',))
1112
1 2 3 4 10
13+
1
14+
two
15+
(True, b'bytes', ())

0 commit comments

Comments
 (0)