[Python-checkins] python/dist/src/Lib/test test_array.py,1.15,1.16 test_types.py,1.32,1.33
mwh@users.sourceforge.net
mwh@users.sourceforge.net
Wed, 19 Jun 2002 08:44:17 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv17321/Lib/test
Modified Files:
test_array.py test_types.py
Log Message:
Fix the bug described in
http://mail.python.org/pipermail/python-dev/2002-June/025461.html
with test cases.
Also includes extended slice support for arrays, which I thought I'd
already checked in but obviously not.
Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_array.py 15 May 2002 13:04:53 -0000 1.15
--- test_array.py 19 Jun 2002 15:44:15 -0000 1.16
***************
*** 4,8 ****
"""
import array
! from test_support import verbose, TESTFN, unlink, TestFailed, have_unicode
def main():
--- 4,9 ----
"""
import array
! from test_support import verbose, TESTFN, unlink, TestFailed,\
! have_unicode, vereq
def main():
***************
*** 313,316 ****
--- 314,357 ----
if a != array.array(type, [4, 3, 1]):
raise TestFailed, "array(%s) reverse-test" % `type`
+ # extended slicing
+ # subscription
+ a = array.array(type, [0,1,2,3,4])
+ vereq(a[::], a)
+ vereq(a[::2], array.array(type, [0,2,4]))
+ vereq(a[1::2], array.array(type, [1,3]))
+ vereq(a[::-1], array.array(type, [4,3,2,1,0]))
+ vereq(a[::-2], array.array(type, [4,2,0]))
+ vereq(a[3::-2], array.array(type, [3,1]))
+ vereq(a[-100:100:], a)
+ vereq(a[100:-100:-1], a[::-1])
+ vereq(a[-100L:100L:2L], array.array(type, [0,2,4]))
+ vereq(a[1000:2000:2], array.array(type, []))
+ vereq(a[-1000:-2000:-2], array.array(type, []))
+ # deletion
+ del a[::2]
+ vereq(a, array.array(type, [1,3]))
+ a = array.array(type, range(5))
+ del a[1::2]
+ vereq(a, array.array(type, [0,2,4]))
+ a = array.array(type, range(5))
+ del a[1::-2]
+ vereq(a, array.array(type, [0,2,3,4]))
+ # assignment
+ a = array.array(type, range(10))
+ a[::2] = array.array(type, [-1]*5)
+ vereq(a, array.array(type, [-1, 1, -1, 3, -1, 5, -1, 7, -1, 9]))
+ a = array.array(type, range(10))
+ a[::-4] = array.array(type, [10]*3)
+ vereq(a, array.array(type, [0, 10, 2, 3, 4, 10, 6, 7, 8 ,10]))
+ a = array.array(type, range(4))
+ a[::-1] = a
+ vereq(a, array.array(type, [3, 2, 1, 0]))
+ a = array.array(type, range(10))
+ b = a[:]
+ c = a[:]
+ ins = array.array(type, range(2))
+ a[2:3] = ins
+ b[slice(2,3)] = ins
+ c[2:3:] = ins
# test that overflow exceptions are raised as expected for assignment
Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** test_types.py 13 Jun 2002 22:23:06 -0000 1.32
--- test_types.py 19 Jun 2002 15:44:15 -0000 1.33
***************
*** 411,414 ****
--- 411,422 ----
a[::-1] = a
vereq(a, [3, 2, 1, 0])
+ a = range(10)
+ b = a[:]
+ c = a[:]
+ a[2:3] = ["two", "elements"]
+ b[slice(2,3)] = ["two", "elements"]
+ c[2:3:] = ["two", "elements"]
+ vereq(a, b)
+ vereq(a, c)
print '6.6 Mappings == Dictionaries'