1 ########################################################################
3 # This software is part of the ast package #
4 # Copyright (c) 1982-2010 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Common Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
13 # Information and Software Systems Research #
17 # David Korn <dgk@research.att.com> #
19 ########################################################################
23 print
-u2 -r ${Command}[$1]: "${@:2}"
26 alias err_exit
='err_exit $LINENO'
30 enum Color_t
=(red green blue orange yellow
)
31 enum
-i Sex_t
=(Male Female
)
32 for ((i
=0; i
< 1000; i
++))
35 [[ $x == red
]] || err_exit
'Color_t does not default to red'
37 [[ $x == orange
]] || err_exit
'$x should be orange'
38 ( x
=violet
) 2> /dev
/null
&& err_exit
'x=violet should fail'
40 [[ ${x[2]} == green
]] || err_exit
'${x[2]} should be green'
41 (( x
[2] == 1 )) || err_exit
'((x[2]!=1))'
42 [[ $
((x
[2])) == 1 ]] || err_exit
'$((x[2]))!=1'
43 [[ $x == orange
]] || err_exit
'$x is no longer orange'
46 [[ ${y[foo]} == yellow
]] || err_exit
'${y[foo]} != yellow'
47 (( y
[foo
] == 4 )) || err_exit
'(( y[foo] != 4))'
49 typeset
-a [Color_t
] z
51 [[ ${z[green]} == xyz
]] || err_exit
'${z[green]} should be xyz'
52 [[ ${z[1]} == xyz
]] || err_exit
'${z[1]} should be xyz'
54 [[ ${!z[@]} == 'green orange' ]] || err_exit
'${!z[@]} == "green orange"'
57 [[ $x == Male
]] || err_exit
'Sex_t not defaulting to Male'
59 [[ $x == Female
]] || err_exit
'Sex_t not case sensitive'
63 typeset
-T X_t
=( typeset name
=aha
)
66 [[ $?
== 1 ]] || err_exit
'typeset -a[X_t] should generate an error message when X-t is not an enumeriation type'