diff options
| author | Dash Peters <dash.peters@gmail.com> | 2023-02-11 18:49:15 -0800 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-03-18 14:10:14 +1100 |
| commit | 7dff38fdc190d7b731fad8319d2ae8aa13fde18a (patch) | |
| tree | 21522a70d61e578e5e8a5dd94ff011736c92f167 /tests/basics/deque_slice.py | |
| parent | cd8eea2ae99542257a33b29c9dfdc02b63fc1bd6 (diff) | |
py/objdeque: Expand implementation to be doubly-ended and support iter.
Add `pop()`, `appendleft()`, and `extend()` methods, support iteration
and indexing, and initializing from an existing sequence.
Iteration and indexing (subscription) have independent configuration flags
to enable them. They are enabled by default at the same level that
collections.deque is enabled (the extra features level).
Also add tests for checking new behavior.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/basics/deque_slice.py')
| -rw-r--r-- | tests/basics/deque_slice.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/basics/deque_slice.py b/tests/basics/deque_slice.py new file mode 100644 index 000000000..367aeea3a --- /dev/null +++ b/tests/basics/deque_slice.py @@ -0,0 +1,29 @@ +try: + from collections import deque +except ImportError: + print("SKIP") + raise SystemExit + +d = deque((), 10) + +d.append(1) +d.append(2) +d.append(3) + +# Index slicing for reads is not supported in CPython +try: + d[0:1] +except TypeError: + print("TypeError") + +# Index slicing for writes is not supported in CPython +try: + d[0:1] = (-1, -2) +except TypeError: + print("TypeError") + +# Index slicing for writes is not supported in CPython +try: + del d[0:1] +except TypeError: + print("TypeError") |
