diff options
Diffstat (limited to 'Test')
-rw-r--r-- | Test/B02typeset.ztst | 55 | ||||
-rw-r--r-- | Test/D04parameter.ztst | 68 |
2 files changed, 123 insertions, 0 deletions
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index b27bb4f6b..ae218047c 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -721,3 +721,58 @@ # 'date' did not run. >Status is printed, 1 *?*: failed to change user ID: * + + typeset -A keyvalhash=([one]=eins [two]=zwei) + keyvalhash+=([three]=drei) + for key in ${(ok)keyvalhash}; do + print $key $keyvalhash[$key] + done +0:[key]=val for hashes +>one eins +>three drei +>two zwei + + local keyvalarray=([1]=one [3]=three) + print -l "${keyvalarray[@]}" + keyvalarray+=([2]=two) + print -l "${keyvalarray[@]}" + local keyvalarray=([1]=one [3]=three) + print -l "${keyvalarray[@]}" +0:[key]=val for normal arrays +>one +> +>three +>one +>two +>three +>one +> +>three + + touch foo Xnot_globbedX + inkey="another key" val="another value" + typeset -A keyvalhash=([$(echo the key)]=$(echo the value) + [$inkey]=$val + [*]=?not_globbed?) + for key in ${(ok)keyvalhash}; do + print -l $key $keyvalhash[$key] + done + typeset -A keyvalhash=([$(echo the key)]=$(echo the value) + [$inkey]=$val + [*]=?not_globbed?) + for key in ${(ok)keyvalhash}; do + print -l $key $keyvalhash[$key] + done +0:Substitution in [key]=val syntax +>* +>?not_globbed? +>another key +>another value +>the key +>the value +>* +>?not_globbed? +>another key +>another value +>the key +>the value diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 8dbc1e8b8..367bca120 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -2207,3 +2207,71 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 0:(z) splitting with remaining tokens >foo-bar*thingy? + typeset -A keyvalhash + keyvalhash=([one]=eins [two]=zwei) + keyvalhash+=([three]=drei) + for key in ${(ok)keyvalhash}; do + print $key $keyvalhash[$key] + done +0:[key]=val for hashes +>one eins +>three drei +>two zwei + + local keyvalarray + keyvalarray=([1]=one [3]=three) + print -l "${keyvalarray[@]}" + keyvalarray+=([2]=two) + print -l "${keyvalarray[@]}" +0:[key]=val for normal arrays +>one +> +>three +>one +>two +>three + + typeset -A keyvalhash + touch foo Xnot_globbedX + key="another key" val="another value" + keyvalhash=([$(echo the key)]=$(echo the value) + [$key]=$val + [*]=?not_globbed?) + for key in ${(ok)keyvalhash}; do + print -l $key $keyvalhash[$key] + done +0:Substitution in [key]=val syntax +>* +>?not_globbed? +>another key +>another value +>the key +>the value + + local keyvalarray + keyvalarray=(1 2 3) + keyvalarray+=([5]=5 [7]=7) + keyvalarray+=([4]=4 [6]=6) + print $#keyvalarray + print $keyvalarray +0:append to normal array using [key]=val +>7 +>1 2 3 4 5 6 7 + + local -A keyvalhash + keyvalhash=(['1first element!']=first' 'value + ["2second element?"]=second" "value + [$'3third element#']=third$' 'value + [\4\f\o\u\r\t\h\ \e\l\e\m\e\n\t\\]=fourth\ value) + for key in ${(ok)keyvalhash}; do + print -rl -- $key $keyvalhash[$key] + done +0:quoting in [key]=value syntax +>1first element! +>first value +>2second element? +>second value +>3third element# +>third value +>4fourth element\ +>fourth value |