diff options
author | Damien George <damien@micropython.org> | 2024-10-30 15:07:58 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-11-04 11:22:43 +1100 |
commit | c88a9d60a17594bfd72d57b073eeb9150019b52c (patch) | |
tree | c2e2d6c0150d35332a5f80007cf3efdb80d8119c | |
parent | 7e1098befe178e4b93657a4d49e6a354037beec4 (diff) | |
download | micropython-c88a9d60a17594bfd72d57b073eeb9150019b52c.tar.gz micropython-c88a9d60a17594bfd72d57b073eeb9150019b52c.zip |
tests/basics/deque2.py: Add tests for deque subscript-from-end.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | tests/basics/deque2.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/deque2.py b/tests/basics/deque2.py index 3552d5be37..ebc0872c7b 100644 --- a/tests/basics/deque2.py +++ b/tests/basics/deque2.py @@ -31,6 +31,16 @@ print(d[0], d[1], d[-1]) d[3] = 5 print(d[3]) +# Access the last element via index, when the last element is at various locations +d = deque((), 2) +for i in range(4): + d.append(i) + print(i, d[-1]) + +# Write the last element then access all elements from the end +d[-1] = 4 +print(d[-2], d[-1]) + # Accessing indices out of bounds raises IndexError try: d[4] |