17c2fbfb3SApril Chin######################################################################## 27c2fbfb3SApril Chin# # 37c2fbfb3SApril Chin# This software is part of the ast package # 4*3e14f97fSRoger A. Faulkner# Copyright (c) 1982-2010 AT&T Intellectual Property # 57c2fbfb3SApril Chin# and is licensed under the # 67c2fbfb3SApril Chin# Common Public License, Version 1.0 # 77c2fbfb3SApril Chin# by AT&T Intellectual Property # 87c2fbfb3SApril Chin# # 97c2fbfb3SApril Chin# A copy of the License is available at # 107c2fbfb3SApril Chin# http://www.opensource.org/licenses/cpl1.0.txt # 117c2fbfb3SApril Chin# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) # 127c2fbfb3SApril Chin# # 137c2fbfb3SApril Chin# Information and Software Systems Research # 147c2fbfb3SApril Chin# AT&T Research # 157c2fbfb3SApril Chin# Florham Park NJ # 167c2fbfb3SApril Chin# # 177c2fbfb3SApril Chin# David Korn <dgk@research.att.com> # 187c2fbfb3SApril Chin# # 197c2fbfb3SApril Chin######################################################################## 207c2fbfb3SApril Chinfunction err_exit 217c2fbfb3SApril Chin{ 227c2fbfb3SApril Chin print -u2 -n "\t" 237c2fbfb3SApril Chin print -u2 -r ${Command}[$1]: "${@:2}" 247c2fbfb3SApril Chin (( Errors+=1 )) 257c2fbfb3SApril Chin} 267c2fbfb3SApril Chinalias err_exit='err_exit $LINENO' 277c2fbfb3SApril Chin 287c2fbfb3SApril ChinCommand=${0##*/} 297c2fbfb3SApril Chininteger Errors=0 307c2fbfb3SApril Chinenum Color_t=(red green blue orange yellow) 317c2fbfb3SApril Chinenum -i Sex_t=(Male Female) 327c2fbfb3SApril Chinfor ((i=0; i < 1000; i++)) 337c2fbfb3SApril Chindo 347c2fbfb3SApril ChinColor_t x 357c2fbfb3SApril Chin[[ $x == red ]] || err_exit 'Color_t does not default to red' 367c2fbfb3SApril Chinx=orange 377c2fbfb3SApril Chin[[ $x == orange ]] || err_exit '$x should be orange' 387c2fbfb3SApril Chin( x=violet) 2> /dev/null && err_exit 'x=violet should fail' 397c2fbfb3SApril Chinx[2]=green 407c2fbfb3SApril Chin[[ ${x[2]} == green ]] || err_exit '${x[2]} should be green' 417c2fbfb3SApril Chin(( x[2] == 1 )) || err_exit '((x[2]!=1))' 427c2fbfb3SApril Chin[[ $((x[2])) == 1 ]] || err_exit '$((x[2]))!=1' 437c2fbfb3SApril Chin[[ $x == orange ]] || err_exit '$x is no longer orange' 447c2fbfb3SApril ChinColor_t -A y 457c2fbfb3SApril Chiny[foo]=yellow 467c2fbfb3SApril Chin[[ ${y[foo]} == yellow ]] || err_exit '${y[foo]} != yellow' 477c2fbfb3SApril Chin(( y[foo] == 4 )) || err_exit '(( y[foo] != 4))' 487c2fbfb3SApril Chinunset y 497c2fbfb3SApril Chintypeset -a [Color_t] z 507c2fbfb3SApril Chinz[green]=xyz 517c2fbfb3SApril Chin[[ ${z[green]} == xyz ]] || err_exit '${z[green]} should be xyz' 527c2fbfb3SApril Chin[[ ${z[1]} == xyz ]] || err_exit '${z[1]} should be xyz' 537c2fbfb3SApril Chinz[orange]=bam 547c2fbfb3SApril Chin[[ ${!z[@]} == 'green orange' ]] || err_exit '${!z[@]} == "green orange"' 557c2fbfb3SApril Chinunset x 567c2fbfb3SApril ChinSex_t x 577c2fbfb3SApril Chin[[ $x == Male ]] || err_exit 'Sex_t not defaulting to Male' 587c2fbfb3SApril Chinx=female 597c2fbfb3SApril Chin[[ $x == Female ]] || err_exit 'Sex_t not case sensitive' 607c2fbfb3SApril Chinunset x y z 617c2fbfb3SApril Chindone 627c2fbfb3SApril Chin( 637c2fbfb3SApril Chintypeset -T X_t=( typeset name=aha ) 647c2fbfb3SApril Chintypeset -a[X_t] arr 657c2fbfb3SApril Chin) 2> /dev/null 667c2fbfb3SApril Chin[[ $? == 1 ]] || err_exit 'typeset -a[X_t] should generate an error message when X-t is not an enumeriation type' 677c2fbfb3SApril Chinexit $Errors 68