2017-04-19 09:49:48 +10:00
|
|
|
# test super() operations which don't require allocation
|
|
|
|
import micropython
|
|
|
|
|
2017-12-11 11:58:44 +02:00
|
|
|
# Check for stackless build, which can't call functions without
|
|
|
|
# allocating a frame on heap.
|
|
|
|
try:
|
2021-03-15 19:27:36 +05:30
|
|
|
|
|
|
|
def stackless():
|
|
|
|
pass
|
|
|
|
|
|
|
|
micropython.heap_lock()
|
|
|
|
stackless()
|
|
|
|
micropython.heap_unlock()
|
2017-12-11 11:58:44 +02:00
|
|
|
except RuntimeError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
2021-03-15 19:27:36 +05:30
|
|
|
|
2017-04-19 09:49:48 +10:00
|
|
|
class A:
|
|
|
|
def foo(self):
|
2021-03-15 19:27:36 +05:30
|
|
|
print("A foo")
|
2017-04-19 09:49:48 +10:00
|
|
|
return 42
|
2021-03-15 19:27:36 +05:30
|
|
|
|
|
|
|
|
2017-04-19 09:49:48 +10:00
|
|
|
class B(A):
|
|
|
|
def foo(self):
|
2021-03-15 19:27:36 +05:30
|
|
|
print("B foo")
|
2017-04-19 09:49:48 +10:00
|
|
|
print(super().foo())
|
|
|
|
|
2021-03-15 19:27:36 +05:30
|
|
|
|
2017-04-19 09:49:48 +10:00
|
|
|
b = B()
|
|
|
|
|
|
|
|
micropython.heap_lock()
|
|
|
|
b.foo()
|
|
|
|
micropython.heap_unlock()
|