1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2026-01-01 20:11:06 +01:00

41773: Array index assignment tests for KSH_ARRAYS

This commit is contained in:
Peter Stephenson 2017-09-27 17:42:09 +01:00
parent 80a02c10aa
commit 7cb55668c2
2 changed files with 69 additions and 1 deletions

View file

@ -12,6 +12,9 @@
2017-09-27 Peter Stephenson <p.stephenson@samsung.com>
* 41773: Test/D04parameter.ztst: Array index assignment tests
for KSH_ARRAYS.
* 41764 (test tweaked): Doc/Zsh/params.yo, Src/params.c,
Src/subst.c, Src/zsh.h, Test/D04parameter.ztst: allow
[key]+=value when modifying array or associative array.

View file

@ -2229,6 +2229,20 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>three
>one
>two
>three
(setopt KSH_ARRAYS
local keyvalarray
keyvalarray=([0]=one [2]=three)
print -l "${keyvalarray[@]}"
keyvalarray+=([1]=two)
print -l "${keyvalarray[@]}")
0:[key]=val for normal arrays with KSH_ARRAYS
>one
>
>three
>one
>two
>three
typeset -A keyvalhash
@ -2256,6 +2270,17 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
print $keyvalarray
0:append to normal array using [key]=val
>7
>1 2 3 4 5 6 7
(setopt KSH_ARRAYS
local keyvalarray
keyvalarray=(1 2 3)
keyvalarray+=([4]=5 [6]=7)
keyvalarray+=([3]=4 [5]=6)
print ${#keyvalarray[*]}
print ${keyvalarray[*]})
0:append to normal array using [key]=val with KSH_ARRAYS
>7
>1 2 3 4 5 6 7
local -A keyvalhash
@ -2286,6 +2311,19 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>
>fifth
>new_sixth
>seventh
(setopt KSH_ARRAYS
local keyvalarray
keyvalarray=(first [1]=second third [5]=sixth seventh [4]=fifth new_sixth)
print -l "${keyvalarray[@]}")
0:mixed syntax [key]=val with normal arrays with KSH_ARRAYS
>first
>second
>third
>
>fifth
>new_sixth
>seventh
local -A keyvalhash
@ -2301,6 +2339,17 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>KVA1one
>KVA2two
>KVA3three
>*
(setopt KSH_ARRAYS
touch KVA1one KVA2two KVA3three
local keyvalarray
keyvalarray=(KVA* [3]=*)
print -l "${keyvalarray[@]}")
0:Globbing in non-[key]=val parts of mixed syntax with KSH_ARRAYS
>KVA1one
>KVA2two
>KVA3three
>*
local -a keyvalarray
@ -2308,6 +2357,14 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
keyvalarray+=([1]+=a [2]=b)
print $keyvalarray
0:Append to element(s) of array
>1a b 3
(setopt KSH_ARRAYS
local -a keyvalarray
keyvalarray=(1 2 3)
keyvalarray+=([0]+=a [1]=b)
print ${keyvalarray[*]})
0:Append to element(s) of array with KSH_ARRAYS
>1a b 3
local -A keyvalhash
@ -2326,7 +2383,15 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
local -a keyvalarray
keyvalarray=([1]=who [2]=anyway [1]+=is [1]+=that [1]+=mysterious [1]+=man)
print -rl -- "${keyvalarray[@]}"
0:Append to element of associative array on creation
0:Append to element of array on creation
>whoisthatmysteriousman
>anyway
(setopt KSH_ARRAYS
local -a keyvalarray
keyvalarray=([0]=who [1]=anyway [0]+=is [0]+=that [0]+=mysterious [0]+=man)
print -rl -- "${keyvalarray[@]}")
0:Append to element of array on creation with KSH_ARRAYS
>whoisthatmysteriousman
>anyway