summaryrefslogtreecommitdiff
path: root/tests/micropython/viper.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-15 22:39:08 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-15 22:39:08 +0100
commita5190a7dac7a73e676d6d649035f846ea92d2d2d (patch)
tree92d64dc58f1515327ae484129a66847f669c6757 /tests/micropython/viper.py
parent2ac4af6946543ae96cf3659468e1b8cabb057f85 (diff)
py: Fix typing of viper locals; allow default types in annotation.
Diffstat (limited to 'tests/micropython/viper.py')
-rw-r--r--tests/micropython/viper.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/micropython/viper.py b/tests/micropython/viper.py
index e1c04784d..2ed70ade6 100644
--- a/tests/micropython/viper.py
+++ b/tests/micropython/viper.py
@@ -10,6 +10,25 @@ def f(x:int, y:int) -> int:
def g(x:object, y:object) -> object:
return x + y
+# a local (should have automatic type int)
+@micropython.viper
+def h(x:int) -> int:
+ y = 4
+ return x + y
+
+# without type annotation, types should default to object
+@micropython.viper
+def i(x, y):
+ return x * y
+
+# a for loop
+@micropython.viper
+def viper_sum(a:int, b:int) -> int:
+ total = 0
+ for x in range(a, b):
+ total += x
+ return total
+
# this doesn't work at the moment
#@micropython.viper
#def g() -> uint:
@@ -17,4 +36,6 @@ def g(x:object, y:object) -> object:
print(f(1, 2))
print(g(1, 2))
-#print(h())
+print(h(3))
+print(i(4, 5))
+print(viper_sum(10, 10000))