summaryrefslogtreecommitdiff
path: root/tests/micropython/viper_binop_divmod.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-10-11 18:54:34 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-11 18:54:34 +1100
commita3afa8cfc46913f471d5eb55da4ae22dee92c25f (patch)
tree09296c9dcd31d6e28ae48e46cce9f08de9123f2d /tests/micropython/viper_binop_divmod.py
parent1b7d6a795149588eb44c1b33dd7c34fe6669460a (diff)
py/emitnative: Implement floor-division and modulo for viper emitter.
Diffstat (limited to 'tests/micropython/viper_binop_divmod.py')
-rw-r--r--tests/micropython/viper_binop_divmod.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/micropython/viper_binop_divmod.py b/tests/micropython/viper_binop_divmod.py
new file mode 100644
index 000000000..822424982
--- /dev/null
+++ b/tests/micropython/viper_binop_divmod.py
@@ -0,0 +1,18 @@
+# test floor-division and modulo operators
+
+@micropython.viper
+def div(x:int, y:int) -> int:
+ return x // y
+
+@micropython.viper
+def mod(x:int, y:int) -> int:
+ return x % y
+
+def dm(x, y):
+ print(div(x, y), mod(x, y))
+
+for x in (-6, 6):
+ for y in range(-7, 8):
+ if y == 0:
+ continue
+ dm(x, y)