From 7cb55668c2b4c559f0cb6a3d72be8eccaa5afa1a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 27 Sep 2017 17:42:09 +0100 Subject: 41773: Array index assignment tests for KSH_ARRAYS --- Test/D04parameter.ztst | 67 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'Test') diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index d6ed6487b..5ffaaa126 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -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 -- cgit 1.4.1