Skip to content

Commit 4d659f5

Browse files
committed
tests: Add feature test for when heap allocation is disabled.
1 parent a053e37 commit 4d659f5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/micropython/heapalloc.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# check that we can do certain things without allocating heap memory
2+
3+
import gc
4+
5+
def f(a):
6+
print(a)
7+
8+
def g(a, b=2):
9+
print(a, b)
10+
11+
global_var = 1
12+
13+
def h():
14+
global global_var
15+
global_var = 2 # set an existing global variable
16+
for i in range(2): # for loop
17+
f(i) # function call
18+
f(i * 2 + 1) # binary operation with small ints
19+
f(a=i) # keyword arguments
20+
g(i) # default arg (second one)
21+
g(i, i) # 2 args
22+
23+
# call h with heap allocation disabled
24+
gc.disable()
25+
h()
26+
gc.enable()

0 commit comments

Comments
 (0)