summaryrefslogtreecommitdiff
path: root/tests/micropython/heapalloc_super.py
blob: a8c23393e487d1711163eaa9f952a880ae4e5632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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()