From bf51e2ff980584603853cc1e7d47b8012316618f Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 2 Apr 2017 17:31:32 +1000 Subject: [PATCH] tests/basics: Add tests for list and bytearray growing using themselves. --- tests/basics/bytearray_slice_assign.py | 5 +++++ tests/basics/list_slice_assign_grow.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tests/basics/bytearray_slice_assign.py b/tests/basics/bytearray_slice_assign.py index 510e784da7..c4b5c43e33 100644 --- a/tests/basics/bytearray_slice_assign.py +++ b/tests/basics/bytearray_slice_assign.py @@ -51,6 +51,11 @@ b = bytearray(10) b[:-1] = bytearray(500) print(len(b), b[0], b[-1]) +# extension with self on RHS +b = bytearray(x) +b[4:] = b +print(b) + # Assignment of bytes to array slice b = bytearray(2) b[1:1] = b"12345" diff --git a/tests/basics/list_slice_assign_grow.py b/tests/basics/list_slice_assign_grow.py index 12b1541e35..fa256235ff 100644 --- a/tests/basics/list_slice_assign_grow.py +++ b/tests/basics/list_slice_assign_grow.py @@ -26,3 +26,8 @@ print(l) l = list(x) l[100:100] = [10, 20, 30, 40] print(l) + +# growing by using itself on RHS +l = list(range(10)) +l[4:] = l +print(l)