Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / tests / array.tests
index 4f5d830..4c17651 100644 (file)
@@ -69,6 +69,8 @@ echo ${#a[5]}
 echo ${#a[@]}
 
 a[4+5/2]="test expression"
+declare a["7 + 8"]="test 2"
+a[7 + 8]="test 2"
 echo ${a[@]}
 
 readonly a[5]
@@ -236,7 +238,15 @@ echo "value = ${barray[*]}"
 set -u
 ( echo ${#narray[4]} )
 
+${THIS_SH} ./array1.sub
+${THIS_SH} ./array2.sub
+
 # some old bugs and ksh93 compatibility tests
+${THIS_SH} ./array3.sub
+
+# some compound assingment parsing problems that showed up in bash-3.1-release
+${THIS_SH} ./array4.sub
+
 set +u
 cd /tmp
 
@@ -245,6 +255,8 @@ foo=([10]="bar")
 echo ${foo[0]}
 rm 1=bar
 
+cd $OLDPWD
+
 foo=(a b c d e f g)
 echo ${foo[@]}
 
@@ -332,3 +344,59 @@ echo ${av[@]: -1:2}
 
 echo out-of-range offset
 echo ${av[@]:12}
+
+# parsing problems and other inconsistencies not fixed until post bash-3.0
+unset x
+declare -a x=(')' $$)
+[ ${x[1]} -eq $$ ] || echo bad
+
+unset x
+declare -a x=(a b c d e)
+echo ${x[4]}
+
+z=([1]=one [4]=four [7]=seven [10]=ten)
+
+echo ${#z[@]}
+
+echo ${!z[@]}
+
+unset x
+declare -a x=(a \'b  c\')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=(a 'b  c')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=($0)
+[ "${x[@]}" = $0 ] || echo double expansion of \$0
+declare -a x=(\$0)
+echo "${x[@]}"
+
+# tests for bash-3.1 problems
+${THIS_SH} ./array5.sub
+
+# tests for post-bash-3.2 problems, most fixed in bash-3.2 patches
+${THIS_SH} ./array6.sub
+${THIS_SH} ./array7.sub
+
+${THIS_SH} ./array8.sub
+
+${THIS_SH} ./array9.sub
+
+${THIS_SH} ./array10.sub
+
+${THIS_SH} ./array11.sub
+
+${THIS_SH} ./array12.sub
+
+${THIS_SH} ./array13.sub
+
+${THIS_SH} ./array14.sub
+
+${THIS_SH} ./array15.sub
+
+${THIS_SH} ./array16.sub