summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/micropython/viper_types.py26
-rw-r--r--tests/micropython/viper_types.py.exp8
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/micropython/viper_types.py b/tests/micropython/viper_types.py
new file mode 100644
index 000000000..ae72c0cf3
--- /dev/null
+++ b/tests/micropython/viper_types.py
@@ -0,0 +1,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))
diff --git a/tests/micropython/viper_types.py.exp b/tests/micropython/viper_types.py.exp
new file mode 100644
index 000000000..b7bef156e
--- /dev/null
+++ b/tests/micropython/viper_types.py.exp
@@ -0,0 +1,8 @@
+False
+True
+False
+True
+False
+True
+False
+True