summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/modulo.py
diff options
context:
space:
mode:
authorRachel Dowdall <rjdowdall@gmail.com>2014-03-22 17:29:27 +0000
committerRachel Dowdall <rjdowdall@gmail.com>2014-03-22 17:29:27 +0000
commitcde8631f15db9941986f8d04534e52462a76094b (patch)
tree56651a2b887a7bfdfef37df391b24d28dac36fc4 /tests/basics/modulo.py
parent721c55dced099a797f0910839c7c4f9ac7599ed4 (diff)
downloadmicropython-cde8631f15db9941986f8d04534e52462a76094b.tar.gz
micropython-cde8631f15db9941986f8d04534e52462a76094b.zip
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
Diffstat (limited to 'tests/basics/modulo.py')
-rw-r--r--tests/basics/modulo.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/basics/modulo.py b/tests/basics/modulo.py
new file mode 100644
index 0000000000..ce7ed2578c
--- /dev/null
+++ b/tests/basics/modulo.py
@@ -0,0 +1,23 @@
+# check modulo matches python definition
+
+print(123 % 7)
+print(-123 % 7)
+print(123 % -7)
+print(-123 % -7)
+
+a = 321
+b = 19
+
+print(a % b)
+print(a % -b)
+print(-a % b)
+print(-a % -b)
+
+
+a = 987654321987987987987987987987
+b = 19
+
+print(a % b)
+print(a % -b)
+print(-a % b)
+print(-a % -b)