#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
#
# This test module contains misc compound tests which do not have
# their own module yet.
#
#
# test setup
function err_exit
{
print -u2 -n "\t"
}
alias err_exit='err_exit $LINENO'
set -o nounset
integer Errors=0
# global utility functions
compound bracketstat=(
integer bopen=0
integer bclose=0
)
function count_brackets
{
typeset x="$1"
typeset c
integer i
for (( i=0 ; i < ${#x} ; i++ )) ; do
c="${x:i:1}"
done
return 0
}
typeset ocwd
typeset tmpdir
# create temporary test directory
tmpdir="$(mktemp -t -d "test_sun_solaris_compound_misc.XXXXXXXX")" || err_exit "Cannot create temporary directory"
# ksh93 <= ast-ksh.2010-03-09 prints garbage for compound x=( compound -a nodes=( [4]=( ) ) );typeset -p x
function test_compound_indexed_array_init_1
{
compound vy
compound vz
compound -a vz.nodes
vz.nodes[4]=( )
cx="$(typeset +p vx.nodes)" ; [[ "$cx" == *-C* && "$cx" == *-a* ]] || err_exit "'$cx' lacks -C/-a attribute"
cy="$(typeset +p vy.nodes)" ; [[ "$cy" == *-C* && "$cy" == *-a* ]] || err_exit "'$cy' lacks -C/-a attribute"
cz="$(typeset +p vz.nodes)" ; [[ "$cz" == *-C* && "$cz" == *-a* ]] || err_exit "'$cz' lacks -C/-a attribute"
return 0
}
# ksh93 <= ast-ksh.2010-03-09 prints garbage for compound x=( compound -a nodes=( [4]=( ) ) );typeset -p x
# this test is the same as test_compound_indexed_array_init_1 but "-a" was replaced with "-A"
{
compound vy
compound vz
compound -A vz.nodes
vz.nodes[4]=( )
cx="$(typeset +p vx.nodes)" ; [[ "$cx" == *-C* && "$cx" == *-A* ]] || err_exit "'$cx' lacks -C/-A attribute"
cy="$(typeset +p vy.nodes)" ; [[ "$cy" == *-C* && "$cy" == *-A* ]] || err_exit "'$cy' lacks -C/-A attribute"
cz="$(typeset +p vz.nodes)" ; [[ "$cz" == *-C* && "$cz" == *-A* ]] || err_exit "'$cz' lacks -C/-A attribute"
return 0
}
# run tests
cd "${ocwd}"
# tests done