blob: f40fcb24070869e5aedc8455f8d4201beb9beaf3 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# tests for natively compiled functions
# basic test
@micropython.native
def native_test(x):
print(1, [], x)
native_test(2)
# check that GC doesn't collect the native function
import gc
gc.collect()
native_test(3)
# native with 2 args
@micropython.native
def f(a, b):
print(a + b)
f(1, 2)
# native with 3 args
@micropython.native
def f(a, b, c):
print(a + b + c)
f(1, 2, 3)
# check not operator
@micropython.native
def f(a):
print(not a)
f(False)
f(True)
# stack settling in branch
@micropython.native
def f(a):
print(1, 2, 3, 4 if a else 5)
f(False)
f(True)
|