summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/list_mult.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-13 13:22:24 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-13 13:22:24 +0100
commit9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2 (patch)
tree79b3b74827761d1db8b2081a2e1e2be24322a527 /tests/basics/list_mult.py
parent9d02780eafd9546354fd3ac429b0211f52331650 (diff)
downloadmicropython-9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2.tar.gz
micropython-9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2.zip
py: Fix mult by negative number of tuple, list, str, bytes.
Multiplication of a tuple, list, str or bytes now yields an empty sequence (instead of crashing). Addresses issue #799 Also added ability to mult bytes on LHS by integer.
Diffstat (limited to 'tests/basics/list_mult.py')
-rw-r--r--tests/basics/list_mult.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/basics/list_mult.py b/tests/basics/list_mult.py
index ec65fbb3f4..16948f74c2 100644
--- a/tests/basics/list_mult.py
+++ b/tests/basics/list_mult.py
@@ -1,4 +1,12 @@
+# basic multiplication
print([0] * 5)
+
+# check negative, 0, positive; lhs and rhs multiplication
+for i in (-4, -2, 0, 2, 4):
+ print(i * [1, 2])
+ print([1, 2] * i)
+
+# check that we don't modify existing list
a = [1, 2, 3]
c = a * 3
-print(c)
+print(a, c)