aboutsummaryrefslogtreecommitdiff
path: root/tests/micropython/viper_types.py
blob: ae72c0cf30285025c3cce60f42c854f46a0f1e27 (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 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))