1*b30d1939SAndy Fiddaman########################################################################
2*b30d1939SAndy Fiddaman#                                                                      #
3*b30d1939SAndy Fiddaman#               This software is part of the ast package               #
4*b30d1939SAndy Fiddaman#          Copyright (c) 1982-2011 AT&T Intellectual Property          #
5*b30d1939SAndy Fiddaman#                      and is licensed under the                       #
6*b30d1939SAndy Fiddaman#                 Eclipse Public License, Version 1.0                  #
7*b30d1939SAndy Fiddaman#                    by AT&T Intellectual Property                     #
8*b30d1939SAndy Fiddaman#                                                                      #
9*b30d1939SAndy Fiddaman#                A copy of the License is available at                 #
10*b30d1939SAndy Fiddaman#          http://www.eclipse.org/org/documents/epl-v10.html           #
11*b30d1939SAndy Fiddaman#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
12*b30d1939SAndy Fiddaman#                                                                      #
13*b30d1939SAndy Fiddaman#              Information and Software Systems Research               #
14*b30d1939SAndy Fiddaman#                            AT&T Research                             #
15*b30d1939SAndy Fiddaman#                           Florham Park NJ                            #
16*b30d1939SAndy Fiddaman#                                                                      #
17*b30d1939SAndy Fiddaman#                  David Korn <dgk@research.att.com>                   #
18*b30d1939SAndy Fiddaman#                                                                      #
19*b30d1939SAndy Fiddaman########################################################################
20*b30d1939SAndy Fiddaman#
21*b30d1939SAndy Fiddaman# Written by Roland Mainz <roland.mainz@nrubsig.org>
22*b30d1939SAndy Fiddaman#
23*b30d1939SAndy Fiddaman
24*b30d1939SAndy Fiddamanfunction err_exit
25*b30d1939SAndy Fiddaman{
26*b30d1939SAndy Fiddaman	print -u2 -n "\t"
27*b30d1939SAndy Fiddaman	print -u2 -r ${Command}[$1]: "${@:2}"
28*b30d1939SAndy Fiddaman	(( Errors < 127 && Errors++ ))
29*b30d1939SAndy Fiddaman}
30*b30d1939SAndy Fiddaman
31*b30d1939SAndy Fiddamanalias err_exit='err_exit $LINENO'
32*b30d1939SAndy Fiddaman
33*b30d1939SAndy Fiddamanset -o nounset
34*b30d1939SAndy FiddamanCommand=${0##*/}
35*b30d1939SAndy Fiddamaninteger Errors=0
36*b30d1939SAndy Fiddaman
37*b30d1939SAndy Fiddaman
38*b30d1939SAndy Fiddaman
39*b30d1939SAndy Fiddamantypeset -T test_t=(
40*b30d1939SAndy Fiddaman	typeset name
41*b30d1939SAndy Fiddaman	typeset cmd
42*b30d1939SAndy Fiddaman	typeset expected_output
43*b30d1939SAndy Fiddaman)
44*b30d1939SAndy Fiddaman
45*b30d1939SAndy Fiddamanfunction testfunc
46*b30d1939SAndy Fiddaman{
47*b30d1939SAndy Fiddaman	integer line_number=$1
48*b30d1939SAndy Fiddaman	typeset cmd="$2"
49*b30d1939SAndy Fiddaman	typeset expected_output="$3"
50*b30d1939SAndy Fiddaman	typeset output
51*b30d1939SAndy Fiddaman
52*b30d1939SAndy Fiddaman	output="$($SHELL -c "${cmd}" 2>&1 )"
53*b30d1939SAndy Fiddaman
54*b30d1939SAndy Fiddaman	[[ "${output}" == "${expected_output}" ]] || err_exit ${line_number} "${output} != ${expected_output}"
55*b30d1939SAndy Fiddaman}
56*b30d1939SAndy Fiddaman
57*b30d1939SAndy Fiddaman# test1: basic tests
58*b30d1939SAndy Fiddamanfunction test1
59*b30d1939SAndy Fiddaman{
60*b30d1939SAndy Fiddaman	# string
61*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { typeset -S x ;     x+="#" ; $1 && print "$x" ; } ; l false ; l false   ; l true)'  "###"
62*b30d1939SAndy Fiddaman	testfunc ${LINENO} 'function  l { typeset -S x=">" ; x+="#" ; $1 && print "$x" ; } ; l false ; l false   ; l true'   ">###"
63*b30d1939SAndy Fiddaman	testfunc ${LINENO} 'function  l { typeset -S x=">" ; x+="#" ; $1 && print "$x" ; } ; l false ; (l false) ; l true'   ">##"
64*b30d1939SAndy Fiddaman	testfunc ${LINENO} 'function  l { typeset -S x=">" ; x+="#" ; $1 && print "$x" ; } ; l false; ( ulimit -c 0 ; l false) ; l true' ">##"
65*b30d1939SAndy Fiddaman
66*b30d1939SAndy Fiddaman	# integer
67*b30d1939SAndy Fiddaman	# (normal)
68*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { integer -S x ;        x+=1 ;   $1 && print "$x" ; } ; l false ; l false   ; l true )' "3"
69*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { integer -S x ;        x+=1 ;   $1 && print "$x" ; } ; l false ; (l false) ; l true )' "2"
70*b30d1939SAndy Fiddaman	# (int)
71*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { typeset -S -i x ;     x+=1 ;   $1 && print "$x" ; } ; l false ; l false   ; l true )' "3"
72*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { typeset -S -i x ;     x+=1 ;   $1 && print "$x" ; } ; l false ; (l false) ; l true )' "2"
73*b30d1939SAndy Fiddaman	# (short)
74*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { typeset -S -s -i x ;  x+=1 ;   $1 && print "$x" ; } ; l false ; l false   ; l true )' "3"
75*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { typeset -S -s -i x ;  x+=1 ;   $1 && print "$x" ; } ; l false ; (l false) ; l true )' "2"
76*b30d1939SAndy Fiddaman
77*b30d1939SAndy Fiddaman	# float
78*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { float -S x=0.5 ;  (( x+=.5 )) ;   $1 && print "$x" ; } ; l false ; l false   ; l true )' "2"
79*b30d1939SAndy Fiddaman	testfunc ${LINENO} '(function l { float -S x=0.5 ;  (( x+=.5 )) ;   $1 && print "$x" ; } ; l false ; (l false) ; l true )' "1.5"
80*b30d1939SAndy Fiddaman
81*b30d1939SAndy Fiddaman	return 0
82*b30d1939SAndy Fiddaman}
83*b30d1939SAndy Fiddaman
84*b30d1939SAndy Fiddaman# test2: test the more complex datatypes
85*b30d1939SAndy Fiddamanfunction test2
86*b30d1939SAndy Fiddaman{
87*b30d1939SAndy Fiddaman        compound out=( typeset stdout stderr ; integer res )
88*b30d1939SAndy Fiddaman	integer i
89*b30d1939SAndy Fiddaman
90*b30d1939SAndy Fiddaman	test_t -r -a tests=(
91*b30d1939SAndy Fiddaman		(
92*b30d1939SAndy Fiddaman			name='compound'
93*b30d1939SAndy Fiddaman			cmd=$'
94*b30d1939SAndy Fiddaman				function l
95*b30d1939SAndy Fiddaman				{
96*b30d1939SAndy Fiddaman					compound -S s=(
97*b30d1939SAndy Fiddaman						integer a=1
98*b30d1939SAndy Fiddaman						integer b=2
99*b30d1939SAndy Fiddaman					)
100*b30d1939SAndy Fiddaman
101*b30d1939SAndy Fiddaman					(( s.a++, s.b++ ))
102*b30d1939SAndy Fiddaman
103*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" s.a s.b
104*b30d1939SAndy Fiddaman				}
105*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
106*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
107*b30d1939SAndy Fiddaman			'
108*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
109*b30d1939SAndy Fiddaman		)
110*b30d1939SAndy Fiddaman		(
111*b30d1939SAndy Fiddaman			name='compound_nameref'
112*b30d1939SAndy Fiddaman			cmd=$'
113*b30d1939SAndy Fiddaman				function l_n
114*b30d1939SAndy Fiddaman				{
115*b30d1939SAndy Fiddaman					nameref sn=$2
116*b30d1939SAndy Fiddaman					(( sn.a++, sn.b++ ))
117*b30d1939SAndy Fiddaman
118*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" sn.a sn.b
119*b30d1939SAndy Fiddaman				}
120*b30d1939SAndy Fiddaman				function l
121*b30d1939SAndy Fiddaman				{
122*b30d1939SAndy Fiddaman					compound -S s=( a=1 b=2 )
123*b30d1939SAndy Fiddaman					l_n $1 s
124*b30d1939SAndy Fiddaman				}
125*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
126*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
127*b30d1939SAndy Fiddaman			'
128*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
129*b30d1939SAndy Fiddaman		)
130*b30d1939SAndy Fiddaman
131*b30d1939SAndy Fiddaman		(
132*b30d1939SAndy Fiddaman			name='type'
133*b30d1939SAndy Fiddaman			cmd=$'
134*b30d1939SAndy Fiddaman				typeset -T ab_t=(
135*b30d1939SAndy Fiddaman					integer a=1
136*b30d1939SAndy Fiddaman					integer b=2
137*b30d1939SAndy Fiddaman
138*b30d1939SAndy Fiddaman					function increment
139*b30d1939SAndy Fiddaman					{
140*b30d1939SAndy Fiddaman						(( _.a++, _.b++ ))
141*b30d1939SAndy Fiddaman					}
142*b30d1939SAndy Fiddaman				)
143*b30d1939SAndy Fiddaman				function l
144*b30d1939SAndy Fiddaman				{
145*b30d1939SAndy Fiddaman					ab_t -S s
146*b30d1939SAndy Fiddaman
147*b30d1939SAndy Fiddaman					s.increment
148*b30d1939SAndy Fiddaman
149*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" s.a s.b
150*b30d1939SAndy Fiddaman				}
151*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
152*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
153*b30d1939SAndy Fiddaman			'
154*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
155*b30d1939SAndy Fiddaman		)
156*b30d1939SAndy Fiddaman
157*b30d1939SAndy Fiddaman		(
158*b30d1939SAndy Fiddaman			name='type_nameref'
159*b30d1939SAndy Fiddaman			cmd=$'
160*b30d1939SAndy Fiddaman				typeset -T ab_t=(
161*b30d1939SAndy Fiddaman					integer a=1
162*b30d1939SAndy Fiddaman					integer b=2
163*b30d1939SAndy Fiddaman
164*b30d1939SAndy Fiddaman					function increment
165*b30d1939SAndy Fiddaman					{
166*b30d1939SAndy Fiddaman						(( _.a++, _.b++ ))
167*b30d1939SAndy Fiddaman					}
168*b30d1939SAndy Fiddaman				)
169*b30d1939SAndy Fiddaman				function l_n
170*b30d1939SAndy Fiddaman				{
171*b30d1939SAndy Fiddaman					nameref sn=$2
172*b30d1939SAndy Fiddaman
173*b30d1939SAndy Fiddaman					sn.increment
174*b30d1939SAndy Fiddaman
175*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" sn.a sn.b
176*b30d1939SAndy Fiddaman				}
177*b30d1939SAndy Fiddaman				function l
178*b30d1939SAndy Fiddaman				{
179*b30d1939SAndy Fiddaman					ab_t -S s
180*b30d1939SAndy Fiddaman					l_n $1 s
181*b30d1939SAndy Fiddaman				}
182*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
183*b30d1939SAndy Fiddaman				(l false ; l false ; l true ; printf ";")
184*b30d1939SAndy Fiddaman			'
185*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
186*b30d1939SAndy Fiddaman		)
187*b30d1939SAndy Fiddaman
188*b30d1939SAndy Fiddaman		(
189*b30d1939SAndy Fiddaman			name='indexed_string_array_appendelement'
190*b30d1939SAndy Fiddaman			cmd=$'
191*b30d1939SAndy Fiddaman				function ar
192*b30d1939SAndy Fiddaman				{
193*b30d1939SAndy Fiddaman					typeset -a -S s=( "hello" )
194*b30d1939SAndy Fiddaman
195*b30d1939SAndy Fiddaman					s+=( "an element" )
196*b30d1939SAndy Fiddaman
197*b30d1939SAndy Fiddaman					$1 && { printf "%s" "${s[@]}" ; printf "\n" ; }
198*b30d1939SAndy Fiddaman				}
199*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
200*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
201*b30d1939SAndy Fiddaman			'
202*b30d1939SAndy Fiddaman			expected_output=$'helloan elementan elementan element\n;helloan elementan elementan element\n;'
203*b30d1939SAndy Fiddaman		)
204*b30d1939SAndy Fiddaman
205*b30d1939SAndy Fiddaman		(
206*b30d1939SAndy Fiddaman			name='indexed_string_array_nameref_appendelement'
207*b30d1939SAndy Fiddaman			cmd=$'
208*b30d1939SAndy Fiddaman				function ar_n
209*b30d1939SAndy Fiddaman				{
210*b30d1939SAndy Fiddaman					nameref sn=$2
211*b30d1939SAndy Fiddaman					sn+=( "an element" )
212*b30d1939SAndy Fiddaman
213*b30d1939SAndy Fiddaman					$1 && { printf "%s" "${sn[@]}" ; printf "\n" ; }
214*b30d1939SAndy Fiddaman				}
215*b30d1939SAndy Fiddaman				function ar
216*b30d1939SAndy Fiddaman				{
217*b30d1939SAndy Fiddaman					typeset -a -S s=( "hello" )
218*b30d1939SAndy Fiddaman					ar_n $1 s
219*b30d1939SAndy Fiddaman				}
220*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
221*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
222*b30d1939SAndy Fiddaman			'
223*b30d1939SAndy Fiddaman			expected_output=$'helloan elementan elementan element\n;helloan elementan elementan element\n;'
224*b30d1939SAndy Fiddaman		)
225*b30d1939SAndy Fiddaman
226*b30d1939SAndy Fiddaman		(
227*b30d1939SAndy Fiddaman			name='associative_string_array_appendelement'
228*b30d1939SAndy Fiddaman			cmd=$'
229*b30d1939SAndy Fiddaman				function ar
230*b30d1939SAndy Fiddaman				{
231*b30d1939SAndy Fiddaman					typeset -A -S s=( [0]="hello" )
232*b30d1939SAndy Fiddaman
233*b30d1939SAndy Fiddaman					s[$(( ${#s[@]} + 1))]="an element"
234*b30d1939SAndy Fiddaman
235*b30d1939SAndy Fiddaman					$1 && { printf "%s" "${s[@]}" ; printf "\n" ; }
236*b30d1939SAndy Fiddaman				}
237*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
238*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
239*b30d1939SAndy Fiddaman			'
240*b30d1939SAndy Fiddaman			expected_output=$'helloan elementan elementan element\n;helloan elementan elementan element\n;'
241*b30d1939SAndy Fiddaman		)
242*b30d1939SAndy Fiddaman
243*b30d1939SAndy Fiddaman		(
244*b30d1939SAndy Fiddaman			name='associative_string_array_nameref_appendelement'
245*b30d1939SAndy Fiddaman			cmd=$'
246*b30d1939SAndy Fiddaman				function ar_n
247*b30d1939SAndy Fiddaman				{
248*b30d1939SAndy Fiddaman					nameref sn=$2
249*b30d1939SAndy Fiddaman
250*b30d1939SAndy Fiddaman					sn[$(( ${#sn[@]} + 1))]="an element"
251*b30d1939SAndy Fiddaman
252*b30d1939SAndy Fiddaman					$1 && { printf "%s" "${sn[@]}" ; printf "\n" ; }
253*b30d1939SAndy Fiddaman				}
254*b30d1939SAndy Fiddaman				function ar
255*b30d1939SAndy Fiddaman				{
256*b30d1939SAndy Fiddaman					typeset -A -S s=( [0]="hello" )
257*b30d1939SAndy Fiddaman					ar_n $1 s
258*b30d1939SAndy Fiddaman				}
259*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
260*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
261*b30d1939SAndy Fiddaman			'
262*b30d1939SAndy Fiddaman			expected_output=$'helloan elementan elementan element\n;helloan elementan elementan element\n;'
263*b30d1939SAndy Fiddaman		)
264*b30d1939SAndy Fiddaman
265*b30d1939SAndy Fiddaman		(
266*b30d1939SAndy Fiddaman			name='indexed_compound_array_editelement'
267*b30d1939SAndy Fiddaman			cmd=$'
268*b30d1939SAndy Fiddaman				function ar
269*b30d1939SAndy Fiddaman				{
270*b30d1939SAndy Fiddaman					compound -S -a s=(
271*b30d1939SAndy Fiddaman						[5]=(
272*b30d1939SAndy Fiddaman							integer a=1
273*b30d1939SAndy Fiddaman							integer b=2
274*b30d1939SAndy Fiddaman						)
275*b30d1939SAndy Fiddaman					)
276*b30d1939SAndy Fiddaman
277*b30d1939SAndy Fiddaman					(( s[5].a++, s[5].b++ ))
278*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" s[5].a s[5].b
279*b30d1939SAndy Fiddaman				}
280*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
281*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
282*b30d1939SAndy Fiddaman			'
283*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
284*b30d1939SAndy Fiddaman		)
285*b30d1939SAndy Fiddaman
286*b30d1939SAndy Fiddaman		(
287*b30d1939SAndy Fiddaman			name='indexed_compound_array_nameref_editelement'
288*b30d1939SAndy Fiddaman			cmd=$'
289*b30d1939SAndy Fiddaman				function ar_n
290*b30d1939SAndy Fiddaman				{
291*b30d1939SAndy Fiddaman					nameref sn=$2
292*b30d1939SAndy Fiddaman
293*b30d1939SAndy Fiddaman					(( sn.a++, sn.b++ ))
294*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" sn.a sn.b
295*b30d1939SAndy Fiddaman				}
296*b30d1939SAndy Fiddaman				function ar
297*b30d1939SAndy Fiddaman				{
298*b30d1939SAndy Fiddaman					compound -S -a s=(
299*b30d1939SAndy Fiddaman						[5]=(
300*b30d1939SAndy Fiddaman							integer a=1
301*b30d1939SAndy Fiddaman							integer b=2
302*b30d1939SAndy Fiddaman						)
303*b30d1939SAndy Fiddaman					)
304*b30d1939SAndy Fiddaman
305*b30d1939SAndy Fiddaman					ar_n $1 s[5]
306*b30d1939SAndy Fiddaman				}
307*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
308*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
309*b30d1939SAndy Fiddaman			'
310*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
311*b30d1939SAndy Fiddaman		)
312*b30d1939SAndy Fiddaman
313*b30d1939SAndy Fiddaman		(
314*b30d1939SAndy Fiddaman			name='2d_indexed_compound_array_editelement'
315*b30d1939SAndy Fiddaman			cmd=$'
316*b30d1939SAndy Fiddaman				function ar
317*b30d1939SAndy Fiddaman				{
318*b30d1939SAndy Fiddaman					compound -S -a s=(
319*b30d1939SAndy Fiddaman						[8][5]=(
320*b30d1939SAndy Fiddaman							integer a=1
321*b30d1939SAndy Fiddaman							integer b=2
322*b30d1939SAndy Fiddaman						)
323*b30d1939SAndy Fiddaman					)
324*b30d1939SAndy Fiddaman
325*b30d1939SAndy Fiddaman					(( s[8][5].a++, s[8][5].b++ ))
326*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" s[8][5].a s[8][5].b
327*b30d1939SAndy Fiddaman				}
328*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
329*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
330*b30d1939SAndy Fiddaman			'
331*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
332*b30d1939SAndy Fiddaman		)
333*b30d1939SAndy Fiddaman
334*b30d1939SAndy Fiddaman		(
335*b30d1939SAndy Fiddaman			name='2d_indexed_compound_array_nameref_editelement'
336*b30d1939SAndy Fiddaman			cmd=$'
337*b30d1939SAndy Fiddaman				function ar_n
338*b30d1939SAndy Fiddaman				{
339*b30d1939SAndy Fiddaman					nameref sn=$2
340*b30d1939SAndy Fiddaman
341*b30d1939SAndy Fiddaman					(( sn.a++, sn.b++ ))
342*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" sn.a sn.b
343*b30d1939SAndy Fiddaman				}
344*b30d1939SAndy Fiddaman				function ar
345*b30d1939SAndy Fiddaman				{
346*b30d1939SAndy Fiddaman					compound -S -a s=(
347*b30d1939SAndy Fiddaman						[8][5]=(
348*b30d1939SAndy Fiddaman							integer a=1
349*b30d1939SAndy Fiddaman							integer b=2
350*b30d1939SAndy Fiddaman						)
351*b30d1939SAndy Fiddaman					)
352*b30d1939SAndy Fiddaman
353*b30d1939SAndy Fiddaman					ar_n $1 s[8][5]
354*b30d1939SAndy Fiddaman				}
355*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
356*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
357*b30d1939SAndy Fiddaman			'
358*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
359*b30d1939SAndy Fiddaman		)
360*b30d1939SAndy Fiddaman		(
361*b30d1939SAndy Fiddaman			name='4d_indexed_compound_array_editelement'
362*b30d1939SAndy Fiddaman			cmd=$'
363*b30d1939SAndy Fiddaman				function ar
364*b30d1939SAndy Fiddaman				{
365*b30d1939SAndy Fiddaman					compound -S -a s=(
366*b30d1939SAndy Fiddaman						[8][5][0][9]=(
367*b30d1939SAndy Fiddaman							integer a=1
368*b30d1939SAndy Fiddaman							integer b=2
369*b30d1939SAndy Fiddaman						)
370*b30d1939SAndy Fiddaman					)
371*b30d1939SAndy Fiddaman
372*b30d1939SAndy Fiddaman					(( s[8][5][0][9].a++, s[8][5][0][9].b++ ))
373*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" s[8][5][0][9].a s[8][5][0][9].b
374*b30d1939SAndy Fiddaman				}
375*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
376*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
377*b30d1939SAndy Fiddaman			'
378*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
379*b30d1939SAndy Fiddaman		)
380*b30d1939SAndy Fiddaman
381*b30d1939SAndy Fiddaman		(
382*b30d1939SAndy Fiddaman			name='4d_indexed_compound_array_nameref_editelement'
383*b30d1939SAndy Fiddaman			cmd=$'
384*b30d1939SAndy Fiddaman				function ar_n
385*b30d1939SAndy Fiddaman				{
386*b30d1939SAndy Fiddaman					nameref sn=$2
387*b30d1939SAndy Fiddaman
388*b30d1939SAndy Fiddaman					(( sn.a++, sn.b++ ))
389*b30d1939SAndy Fiddaman					$1 && printf "a=%d, b=%d\n" sn.a sn.b
390*b30d1939SAndy Fiddaman				}
391*b30d1939SAndy Fiddaman				function ar
392*b30d1939SAndy Fiddaman				{
393*b30d1939SAndy Fiddaman					compound -S -a s=(
394*b30d1939SAndy Fiddaman						[8][5][0][9]=(
395*b30d1939SAndy Fiddaman							integer a=1
396*b30d1939SAndy Fiddaman							integer b=2
397*b30d1939SAndy Fiddaman						)
398*b30d1939SAndy Fiddaman					)
399*b30d1939SAndy Fiddaman
400*b30d1939SAndy Fiddaman					ar_n $1 s[8][5][0][9]
401*b30d1939SAndy Fiddaman				}
402*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
403*b30d1939SAndy Fiddaman				(ar false ; ar false ; ar true ; printf ";")
404*b30d1939SAndy Fiddaman			'
405*b30d1939SAndy Fiddaman			expected_output=$'a=4, b=5\n;a=4, b=5\n;'
406*b30d1939SAndy Fiddaman		)
407*b30d1939SAndy Fiddaman
408*b30d1939SAndy Fiddaman		(
409*b30d1939SAndy Fiddaman			name='associative_compound_array_editelement'
410*b30d1939SAndy Fiddaman			cmd=$'
411*b30d1939SAndy Fiddaman				function ar
412*b30d1939SAndy Fiddaman				{
413