18462SApril.Chin@Sun.COM######################################################################## 28462SApril.Chin@Sun.COM# # 38462SApril.Chin@Sun.COM# This software is part of the ast package # 4*12068SRoger.Faulkner@Oracle.COM# Copyright (c) 1982-2010 AT&T Intellectual Property # 58462SApril.Chin@Sun.COM# and is licensed under the # 68462SApril.Chin@Sun.COM# Common Public License, Version 1.0 # 78462SApril.Chin@Sun.COM# by AT&T Intellectual Property # 88462SApril.Chin@Sun.COM# # 98462SApril.Chin@Sun.COM# A copy of the License is available at # 108462SApril.Chin@Sun.COM# http://www.opensource.org/licenses/cpl1.0.txt # 118462SApril.Chin@Sun.COM# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) # 128462SApril.Chin@Sun.COM# # 138462SApril.Chin@Sun.COM# Information and Software Systems Research # 148462SApril.Chin@Sun.COM# AT&T Research # 158462SApril.Chin@Sun.COM# Florham Park NJ # 168462SApril.Chin@Sun.COM# # 178462SApril.Chin@Sun.COM# David Korn <dgk@research.att.com> # 188462SApril.Chin@Sun.COM# # 198462SApril.Chin@Sun.COM######################################################################## 208462SApril.Chin@Sun.COMfunction err_exit 218462SApril.Chin@Sun.COM{ 228462SApril.Chin@Sun.COM print -u2 -n "\t" 238462SApril.Chin@Sun.COM print -u2 -r ${Command}[$1]: "${@:2}" 248462SApril.Chin@Sun.COM (( Errors+=1 )) 258462SApril.Chin@Sun.COM} 268462SApril.Chin@Sun.COMalias err_exit='err_exit $LINENO' 278462SApril.Chin@Sun.COM 288462SApril.Chin@Sun.COMCommand=${0##*/} 298462SApril.Chin@Sun.COMinteger Errors=0 308462SApril.Chin@Sun.COMenum Color_t=(red green blue orange yellow) 318462SApril.Chin@Sun.COMenum -i Sex_t=(Male Female) 328462SApril.Chin@Sun.COMfor ((i=0; i < 1000; i++)) 338462SApril.Chin@Sun.COMdo 348462SApril.Chin@Sun.COMColor_t x 358462SApril.Chin@Sun.COM[[ $x == red ]] || err_exit 'Color_t does not default to red' 368462SApril.Chin@Sun.COMx=orange 378462SApril.Chin@Sun.COM[[ $x == orange ]] || err_exit '$x should be orange' 388462SApril.Chin@Sun.COM( x=violet) 2> /dev/null && err_exit 'x=violet should fail' 398462SApril.Chin@Sun.COMx[2]=green 408462SApril.Chin@Sun.COM[[ ${x[2]} == green ]] || err_exit '${x[2]} should be green' 418462SApril.Chin@Sun.COM(( x[2] == 1 )) || err_exit '((x[2]!=1))' 428462SApril.Chin@Sun.COM[[ $((x[2])) == 1 ]] || err_exit '$((x[2]))!=1' 438462SApril.Chin@Sun.COM[[ $x == orange ]] || err_exit '$x is no longer orange' 448462SApril.Chin@Sun.COMColor_t -A y 458462SApril.Chin@Sun.COMy[foo]=yellow 4610898Sroland.mainz@nrubsig.org[[ ${y[foo]} == yellow ]] || err_exit '${y[foo]} != yellow' 4710898Sroland.mainz@nrubsig.org(( y[foo] == 4 )) || err_exit '(( y[foo] != 4))' 488462SApril.Chin@Sun.COMunset y 498462SApril.Chin@Sun.COMtypeset -a [Color_t] z 508462SApril.Chin@Sun.COMz[green]=xyz 518462SApril.Chin@Sun.COM[[ ${z[green]} == xyz ]] || err_exit '${z[green]} should be xyz' 528462SApril.Chin@Sun.COM[[ ${z[1]} == xyz ]] || err_exit '${z[1]} should be xyz' 538462SApril.Chin@Sun.COMz[orange]=bam 548462SApril.Chin@Sun.COM[[ ${!z[@]} == 'green orange' ]] || err_exit '${!z[@]} == "green orange"' 558462SApril.Chin@Sun.COMunset x 568462SApril.Chin@Sun.COMSex_t x 578462SApril.Chin@Sun.COM[[ $x == Male ]] || err_exit 'Sex_t not defaulting to Male' 588462SApril.Chin@Sun.COMx=female 598462SApril.Chin@Sun.COM[[ $x == Female ]] || err_exit 'Sex_t not case sensitive' 608462SApril.Chin@Sun.COMunset x y z 618462SApril.Chin@Sun.COMdone 628462SApril.Chin@Sun.COM( 638462SApril.Chin@Sun.COMtypeset -T X_t=( typeset name=aha ) 648462SApril.Chin@Sun.COMtypeset -a[X_t] arr 658462SApril.Chin@Sun.COM) 2> /dev/null 668462SApril.Chin@Sun.COM[[ $? == 1 ]] || err_exit 'typeset -a[X_t] should generate an error message when X-t is not an enumeriation type' 678462SApril.Chin@Sun.COMexit $Errors 68