circuitpython/tests/micropython/heapalloc_super.py
Scott Shawcroft b057fb8a4b
codeformat
2021-04-19 22:22:44 -07:00

36 lines
571 B
Python

# test super() operations which don't require allocation
import micropython
# Check for stackless build, which can't call functions without
# allocating a frame on heap.
try:
def stackless():
pass
micropython.heap_lock()
stackless()
micropython.heap_unlock()
except RuntimeError:
print("SKIP")
raise SystemExit
class A:
def foo(self):
print("A foo")
return 42
class B(A):
def foo(self):
print("B foo")
print(super().foo())
b = B()
micropython.heap_lock()
b.foo()
micropython.heap_unlock()