summaryrefslogtreecommitdiff
path: root/tests/micropython
diff options
context:
space:
mode:
Diffstat (limited to 'tests/micropython')
-rw-r--r--tests/micropython/viper_binop_divmod.py18
-rw-r--r--tests/micropython/viper_binop_divmod.py.exp28
2 files changed, 46 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)
diff --git a/tests/micropython/viper_binop_divmod.py.exp b/tests/micropython/viper_binop_divmod.py.exp
new file mode 100644
index 000000000..4fc971d46
--- /dev/null
+++ b/tests/micropython/viper_binop_divmod.py.exp
@@ -0,0 +1,28 @@
+0 -6
+1 0
+1 -1
+1 -2
+2 0
+3 0
+6 0
+-6 0
+-3 0
+-2 0
+-2 2
+-2 4
+-1 0
+-1 1
+-1 -1
+-1 0
+-2 -4
+-2 -2
+-2 0
+-3 0
+-6 0
+6 0
+3 0
+2 0
+1 2
+1 1
+1 0
+0 6