summaryrefslogtreecommitdiff
path: root/tests/micropython/viper.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-15 16:45:41 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-15 16:45:41 +0100
commit2ac4af6946543ae96cf3659468e1b8cabb057f85 (patch)
tree2e19460fec67666259afe529e7f4dff71b6451cf /tests/micropython/viper.py
parent6be0b0a8ec9a6badc601190ccee876755ce7efb7 (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/viper.py')
-rw-r--r--tests/micropython/viper.py20
1 files changed, 20 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())