summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-09-27 17:42:09 +0100
committerPeter Stephenson <pws@zsh.org>2017-09-28 10:59:38 +0100
commit7cb55668c2b4c559f0cb6a3d72be8eccaa5afa1a (patch)
tree293568779b939c72e10ebc78dd79ffc41d1c6471
parent80a02c10aa85c1b57376faede83cb90a8079c5d7 (diff)
downloadzsh-7cb55668c2b4c559f0cb6a3d72be8eccaa5afa1a.tar.gz
zsh-7cb55668c2b4c559f0cb6a3d72be8eccaa5afa1a.zip
41773: Array index assignment tests for KSH_ARRAYS
-rw-r--r--ChangeLog3
-rw-r--r--Test/D04parameter.ztst67
2 files changed, 69 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 371f08ca8..959f7d000 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index d6ed6487b..5ffaaa126 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2231,6 +2231,20 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>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
touch foo Xnot_globbedX
key="another key" val="another value"
@@ -2258,6 +2272,17 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>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
keyvalhash=(['1first element!']=first' 'value
["2second element?"]=second" "value
@@ -2288,6 +2313,19 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>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
keyvalhash=(1 one [2]=two 3 three)
1:Mixed syntax with [key]=val not allowed for hash.
@@ -2303,6 +2341,17 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>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
keyvalarray=(1 2 3)
keyvalarray+=([1]+=a [2]=b)
@@ -2310,6 +2359,14 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
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
keyvalhash=([a]=a [b]=b [c]=c)
keyvalhash+=([a]+=yee [b]=ee)
@@ -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