aboutsummaryrefslogtreecommitdiff
path: root/tests/micropython/viper_types.py
blob: 3af148171e298d69a1b96d1cabb0b55eb3d49cdb (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
# test various type conversions

import micropython

# converting incoming arg to bool
@micropython.viper
def f1(x: bool):
    print(x)


f1(0)
f1(1)
f1([])
f1([1])

# taking and returning a bool
@micropython.viper
def f2(x: bool) -> bool:
    return x


print(f2([]))
print(f2([1]))

# converting to bool within function
@micropython.viper
def f3(x) -> bool:
    return bool(x)


print(f3([]))
print(f3(-1))