diff options
author | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 |
commit | 9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2 (patch) | |
tree | 79b3b74827761d1db8b2081a2e1e2be24322a527 /tests/basics/list_mult.py | |
parent | 9d02780eafd9546354fd3ac429b0211f52331650 (diff) | |
download | micropython-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.py | 10 |
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) |