summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-07-16 15:29:06 (GMT)
committerGuido van Rossum <guido@python.org>1998-07-16 15:29:06 (GMT)
commitaffd77f71e7f24aa7a376ca6c6724581deb1b6cd (patch)
tree21c23602d2981f8aaebab13aaa6a8bfbb0830c13 /Lib/test
parent0fd00334c676e680818453eee50a7998889e6ca9 (diff)
downloadcpython-affd77f71e7f24aa7a376ca6c6724581deb1b6cd.zip
cpython-affd77f71e7f24aa7a376ca6c6724581deb1b6cd.tar.gz
cpython-affd77f71e7f24aa7a376ca6c6724581deb1b6cd.tar.bz2
Add tests for list self-assigns. (Sorry, this should have been here
before JPython 1.0 came out.)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_types.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 685c05b..072e6d2 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -134,6 +134,19 @@ if 0*[1,2,3] <> []: raise TestFailed, 'list repetition 0*'
if min([1,2]) <> 1 or max([1,2]) <> 2: raise TestFailed, 'min/max list'
if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass
else: raise TestFailed, 'in/not in list'
+a = [1, 2, 3, 4, 5]
+a[:-1] = a
+if a != [1, 2, 3, 4, 5, 5]:
+ raise TestFailed, "list self-slice-assign (head)"
+a = [1, 2, 3, 4, 5]
+a[1:] = a
+if a != [1, 1, 2, 3, 4, 5]:
+ raise TestFailed, "list self-slice-assign (tail)"
+a = [1, 2, 3, 4, 5]
+a[1:-1] = a
+if a != [1, 1, 2, 3, 4, 5, 5]:
+ raise TestFailed, "list self-slice-assign (center)"
+
print '6.5.3a Additional list operations'
a = [0,1,2,3,4]