1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-07 15:56:04 +02:00

users/15663: some incomplete array assignment tests

This commit is contained in:
Peter Stephenson 2010-12-21 11:00:14 +00:00
parent b3589121b3
commit d3ec328926
2 changed files with 103 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2010-12-21 Peter Stephenson <pws@csr.com>
* users/15663: Test/A06Assign.ztst: some (incomplete) array
assignment tests.
* unposted: Config/version.mk: update version to 4.3.11-dev-1.
2010-12-20 Peter Stephenson <pws@csr.com>
@ -14021,5 +14024,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5164 $
* $Revision: 1.5165 $
*****************************************************

View File

@ -7,6 +7,105 @@
1:assign to association with odd no. of values
?(eval):2: bad set of key/value pairs for associative array
# tests of array element assignment
array=(1 2 3 4 5)
array[1]=42
print $array
0:Replacement of array element
>42 2 3 4 5
array=(1 2 3 4 5)
array[1]=(42 43)
print $array
0:Replacement of array element with array
>42 43 2 3 4 5
array=(1 2 3 4 5)
array[1,2]=(42 43)
print $array
0:Replacement of start of array
>42 43 3 4 5
array=(1 2 3 4 5)
array[1,4]=(42 43)
print $array
0:Replacement of start of array with shorter slice
>42 43 5
array=(1 2 3 4 5)
array[1,6]=(42 43)
print $array
0:Replacement of array by extending slice
>42 43
array=(1 2 3 4 5)
array[3]=(42 43)
print $array
0:Replacement of middle element with array
>1 2 42 43 4 5
array=(1 2 3 4 5)
array[3,4]=(42 43 44)
print $array
0:Replacement of slice in middle
>1 2 42 43 44 5
array=(1 2 3 4 5)
array[7,8]=(42 43)
print $array
# check that [6] was left empty...
array[6]=41
print $array
0:Appending by replacing elements off the end
>1 2 3 4 5 42 43
>1 2 3 4 5 41 42 43
array=(1 2 3 4 5)
array[-1]=42
print $array
0:Replacement of last element of array, negative indices
>1 2 3 4 42
array=(1 2 3 4 5)
array[-1]=(42 43)
print $array
0:Replacement of last element of array with array, negative indices
>1 2 3 4 42 43
array=(1 2 3 4 5)
array[-3,-2]=(42 43 44)
print $array
0:Replacement of middle of array, negative indices
>1 2 42 43 44 5
array=(1 2 3 4 5)
array[-5,-1]=(42 43)
print $array
0:Replacement of entire array, negative indices
>42 43
array=(1 2 3 4 5)
array[-7,-1]=(42 43)
print $array
0:Replacement of more than entire array, negative indices
>42 43
array=(1 2 3 4 5)
array[-7]=42
print $array
0:Replacement of element off start of array.
>42 1 2 3 4 5
array=(1 2 3 4 5)
array[-7]=42
array[-6]=43
print $array
0:Replacement off start doesn't leave gaps. Hope this is right.
>43 1 2 3 4 5
# TODO: mixed indices [-num,num] and [num,-num]
# tests of var+=scalar
s+=foo