From 2ac4af6946543ae96cf3659468e1b8cabb057f85 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 15 Aug 2014 16:45:41 +0100 Subject: 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 --- tests/micropython/viper.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/micropython/viper.py (limited to 'tests/micropython/viper.py') 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()) -- cgit v1.2.3