summaryrefslogtreecommitdiff
path: root/tests/micropython/heapalloc_super.py
blob: 51afae3d83d06c8c8ed2d7d9b851932a3075bc9c (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
27
28
29
30
31
32
33
34
35
# 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()