[Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.12,1.13
Andrew M. Kuchling
akuchlin@CNRI.Reston.VA.US
Wed, 23 Feb 2000 17:23:20 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Lib/test
In directory amarok:/home/akuchlin/src/Python-1.5/Lib/test
Modified Files:
test_types.py
Log Message:
Add tests to exercise sequence operations (multiplication, indexing,
slicing) using long integers
Index: test_types.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** test_types.py 1998/07/16 15:29:06 1.12
--- test_types.py 2000/02/23 22:23:17 1.13
***************
*** 131,135 ****
--- 131,137 ----
if [1,2]+[3,4] <> [1,2,3,4]: raise TestFailed, 'list concatenation'
if [1,2]*3 <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3'
+ if [1,2]*3L <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L'
if 0*[1,2,3] <> []: raise TestFailed, 'list repetition 0*'
+ if 0L*[1,2,3] <> []: raise TestFailed, 'list repetition 0L*'
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
***************
*** 151,158 ****
--- 153,167 ----
print '6.5.3a Additional list operations'
a = [0,1,2,3,4]
+ a[0L] = 1
+ a[1L] = 2
+ a[2L] = 3
+ if a <> [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]'
a[0] = 5
a[1] = 6
a[2] = 7
if a <> [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]'
+ a[-2L] = 88
+ a[-1L] = 99
+ if a <> [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]'
a[-2] = 8
a[-1] = 9
***************
*** 162,165 ****
--- 171,176 ----
a[1:1] = [1,2,3]
if a <> [0,1,2,3,4]: raise TestFailed, 'list slice assignment'
+ a[ 1L : 4L] = [7,8,9]
+ if a <> [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints'
del a[1:4]
if a <> [0,4]: raise TestFailed, 'list slice deletion'
***************
*** 168,171 ****
--- 179,189 ----
del a[-1]
if a <> []: raise TestFailed, 'list item deletion [-1]'
+ a=range(0,5)
+ del a[1L:4L]
+ if a <> [0,4]: raise TestFailed, 'list slice deletion'
+ del a[0L]
+ if a <> [4]: raise TestFailed, 'list item deletion [0]'
+ del a[-1L]
+ if a <> []: raise TestFailed, 'list item deletion [-1]'
a.append(0)
a.append(1)
***************
*** 192,195 ****
--- 210,220 ----
z = range(12)
z.sort(myComparison)
+
+ # Test extreme cases with long ints
+ a = [0,1,2,3,4]
+ if a[ -pow(2,128L): 3 ] != [0,1,2]:
+ raise TestFailed, "list slicing with too-small long integer"
+ if a[ 3: pow(2,145L) ] != [3,4]:
+ raise TestFailed, "list slicing with too-large long integer"
print '6.6 Mappings == Dictionaries'