diff options
author | Damien George <damien.p.george@gmail.com> | 2014-08-15 22:39:08 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-08-15 22:39:08 +0100 |
commit | a5190a7dac7a73e676d6d649035f846ea92d2d2d (patch) | |
tree | 92d64dc58f1515327ae484129a66847f669c6757 /tests/micropython/viper.py | |
parent | 2ac4af6946543ae96cf3659468e1b8cabb057f85 (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.py | 23 |
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)) |