[pypy-commit] pypy fix-2198: Add new test cases for assigning slices
Vincent Legoll
pypy.commits at gmail.com
Sat Dec 19 14:22:23 EST 2015
Author: Vincent Legoll <vincent.legoll at idgrilles.fr>
Branch: fix-2198
Changeset: r81398:f0c46bb74141
Date: 2015-12-19 10:18 +0100
http://bitbucket.org/pypy/pypy/changeset/f0c46bb74141/
Log: Add new test cases for assigning slices
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1003,6 +1003,8 @@
l = l0 = ['a', 'b']
l[1:1] = ['ae']
assert l == ['a', 'ae', 'b']
+ l[1:1] = []
+ assert l == ['a', 'ae', 'b']
l[1:100] = ['B']
assert l == ['a', 'B']
l[:] = []
@@ -1010,9 +1012,10 @@
assert l is l0
l = []
- l2 = range(3)
- l.__setslice__(0,3,l2)
- assert l == [0,1,2]
+ length = 3
+ l2 = range(length)
+ l.__setslice__(0, length, l2)
+ assert l == range(length)
def test_assign_extended_slice(self):
l = l0 = ['a', 'b', 'c']
@@ -1043,13 +1046,10 @@
l[:] = l
assert l == [1,2,3,4]
- l = [1,2,3,4]
+ l = l0 = [1,2,3,4]
l[0:2] = l
assert l == [1,2,3,4,3,4]
-
- l = [1,2,3,4]
- l[0:2] = l
- assert l == [1,2,3,4,3,4]
+ assert l0 is l
l = [1,2,3,4,5,6,7,8,9,10]
raises(ValueError, "l[5::-1] = l")
@@ -1061,6 +1061,11 @@
l[5:] = l
assert l == [1,2,3,4,5,1,2,3,4,5,6,7,8,9,10]
+ l = l0 = [1,2,3,4,5,6]
+ raises(ValueError, "l[::-2] = l")
+ assert l == [1,2,3,4,5,6]
+ assert l is l0
+
l = [1,2,3,4,5,6]
l[::-1] = l
assert l == [6,5,4,3,2,1]
@@ -1337,6 +1342,10 @@
l.__setslice__(0, 2, [5, 6])
assert l == [5, 6, 3, 4]
+ l = [1,2,3,4]
+ l.__setslice__(-2, -1, [5, 6])
+ assert l == [5, 6, 1, 2, 3,4]
+
l = []
l.__setslice__(0,0,[3,4,5])
assert l == [3,4,5]
More information about the pypy-commit
mailing list