summaryrefslogtreecommitdiff
path: root/tests/micropython/heapalloc.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-05-31 18:33:16 +0100
committerDamien George <damien.p.george@gmail.com>2014-05-31 18:33:16 +0100
commit4d659f566f094a42057023dcc82a3ca8810c5ba6 (patch)
tree0f53abd6f50478fa8eb21fb018515bc35a2748de /tests/micropython/heapalloc.py
parenta053e37b2cd453db35ca28e5292e24ec898e585f (diff)
tests: Add feature test for when heap allocation is disabled.
Diffstat (limited to 'tests/micropython/heapalloc.py')
-rw-r--r--tests/micropython/heapalloc.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/micropython/heapalloc.py b/tests/micropython/heapalloc.py
new file mode 100644
index 000000000..c62428a08
--- /dev/null
+++ b/tests/micropython/heapalloc.py
@@ -0,0 +1,26 @@
+# check that we can do certain things without allocating heap memory
+
+import gc
+
+def f(a):
+ print(a)
+
+def g(a, b=2):
+ print(a, b)
+
+global_var = 1
+
+def h():
+ global global_var
+ global_var = 2 # set an existing global variable
+ for i in range(2): # for loop
+ f(i) # function call
+ f(i * 2 + 1) # binary operation with small ints
+ f(a=i) # keyword arguments
+ g(i) # default arg (second one)
+ g(i, i) # 2 args
+
+# call h with heap allocation disabled
+gc.disable()
+h()
+gc.enable()