diff options
| author | Damien George | 2014-08-15 16:45:41 +0100 |
|---|---|---|
| committer | Damien George | 2014-08-15 16:45:41 +0100 |
| commit | 2ac4af6946543ae96cf3659468e1b8cabb057f85 (patch) | |
| tree | 2e19460fec67666259afe529e7f4dff71b6451cf /tests/micropython | |
| parent | 6be0b0a8ec9a6badc601190ccee876755ce7efb7 (diff) | |
py: Allow viper to have type annotations.
Viper functions can now be annotated with the type of their arguments
and return value. Eg:
@micropython.viper
def f(x:int) -> int:
return x + 1
Diffstat (limited to 'tests/micropython')
| -rw-r--r-- | tests/micropython/viper.py | 20 | ||||
| -rw-r--r-- | tests/micropython/viper.py.exp | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/micropython/viper.py b/tests/micropython/viper.py new file mode 100644 index 000000000..e1c04784d --- /dev/null +++ b/tests/micropython/viper.py @@ -0,0 +1,20 @@ +import micropython + +# viper function taking and returning ints +@micropython.viper +def f(x:int, y:int) -> int: + return x + y + 3 + +# viper function taking and returning objects +@micropython.viper +def g(x:object, y:object) -> object: + return x + y + +# this doesn't work at the moment +#@micropython.viper +#def g() -> uint: +# return -1 + +print(f(1, 2)) +print(g(1, 2)) +#print(h()) diff --git a/tests/micropython/viper.py.exp b/tests/micropython/viper.py.exp new file mode 100644 index 000000000..7ea2ad9b2 --- /dev/null +++ b/tests/micropython/viper.py.exp @@ -0,0 +1,2 @@ +6 +3 |
