summaryrefslogtreecommitdiff
path: root/tests/micropython/heapalloc_fail_dict.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/micropython/heapalloc_fail_dict.py')
-rw-r--r--tests/micropython/heapalloc_fail_dict.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/micropython/heapalloc_fail_dict.py b/tests/micropython/heapalloc_fail_dict.py
new file mode 100644
index 000000000..ba872bfeb
--- /dev/null
+++ b/tests/micropython/heapalloc_fail_dict.py
@@ -0,0 +1,21 @@
+# test handling of failed heap allocation with dict
+
+import micropython
+
+# create dict
+x = 1
+micropython.heap_lock()
+try:
+ {x:x}
+except MemoryError:
+ print('MemoryError: create dict')
+micropython.heap_unlock()
+
+# create dict view
+x = {1:1}
+micropython.heap_lock()
+try:
+ x.items()
+except MemoryError:
+ print('MemoryError: dict.items')
+micropython.heap_unlock()