mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Add tests for array self-assigns. (This one has no relevance to JPython.)
This commit is contained in:
		
							parent
							
								
									affd77f71e
								
							
						
					
					
						commit
						7f1d3aa3d9
					
				
					 1 changed files with 28 additions and 1 deletions
				
			
		|  | @ -3,7 +3,7 @@ | |||
|    Roger E. Masse | ||||
| """ | ||||
| import array | ||||
| from test_support import verbose, TESTFN, unlink | ||||
| from test_support import verbose, TESTFN, unlink, TestFailed | ||||
| 
 | ||||
| def main(): | ||||
| 
 | ||||
|  | @ -54,6 +54,33 @@ def testtype(type, example): | |||
|             print 'array of %s converted to a string: ' \ | ||||
|                    % a.typecode, `a.tostring()` | ||||
| 
 | ||||
|         if type == 'c': | ||||
|             a = array.array(type, "abcde") | ||||
|             a[:-1] = a | ||||
|             if a != array.array(type, "abcdee"): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (head)" % `type` | ||||
|             a = array.array(type, "abcde") | ||||
|             a[1:] = a | ||||
|             if a != array.array(type, "aabcde"): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (tail)" % `type` | ||||
|             a = array.array(type, "abcde") | ||||
|             a[1:-1] = a | ||||
|             if a != array.array(type, "aabcdee"): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` | ||||
|         else: | ||||
|             a = array.array(type, [1, 2, 3, 4, 5]) | ||||
|             a[:-1] = a | ||||
|             if a != array.array(type, [1, 2, 3, 4, 5, 5]): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (head)" % `type` | ||||
|             a = array.array(type, [1, 2, 3, 4, 5]) | ||||
|             a[1:] = a | ||||
|             if a != array.array(type, [1, 1, 2, 3, 4, 5]): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (tail)" % `type` | ||||
|             a = array.array(type, [1, 2, 3, 4, 5]) | ||||
|             a[1:-1] = a | ||||
|             if a != array.array(type, [1, 1, 2, 3, 4, 5, 5]): | ||||
|                 raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` | ||||
| 
 | ||||
| 
 | ||||
| main() | ||||
|          | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum