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 | |
parent | 2ac4af6946543ae96cf3659468e1b8cabb057f85 (diff) | |
download | micropython-a5190a7dac7a73e676d6d649035f846ea92d2d2d.tar.gz micropython-a5190a7dac7a73e676d6d649035f846ea92d2d2d.zip |
py: Fix typing of viper locals; allow default types in annotation.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/micropython/viper.py | 23 | ||||
-rw-r--r-- | tests/micropython/viper.py.exp | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/micropython/viper.py b/tests/micropython/viper.py index e1c04784df..2ed70ade60 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)) diff --git a/tests/micropython/viper.py.exp b/tests/micropython/viper.py.exp index 7ea2ad9b22..6ee698f66a 100644 --- a/tests/micropython/viper.py.exp +++ b/tests/micropython/viper.py.exp @@ -1,2 +1,5 @@ 6 3 +7 +20 +49994955 |