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 let Errors+=1 257c2fbfb3SApril Chin} 267c2fbfb3SApril Chinalias err_exit='err_exit $LINENO' 277c2fbfb3SApril Chin 287c2fbfb3SApril ChinCommand=${0##*/} 297c2fbfb3SApril Chininteger Errors=0 307c2fbfb3SApril Chinfor ((i=0; i < 4; i++ )) 317c2fbfb3SApril Chindo for ((j=0; j < 5; j++ )) 327c2fbfb3SApril Chin do a[i][j]=$i$j 337c2fbfb3SApril Chin done 347c2fbfb3SApril Chindone 357c2fbfb3SApril Chinfor ((i=0; i < 4; i++ )) 367c2fbfb3SApril Chindo for ((j=0; j < 5; j++ )) 377c2fbfb3SApril Chin do [[ ${a[i][j]} == "$i$j" ]] || err_exit "\${a[$i][$j]} != $i$j" 387c2fbfb3SApril Chin done 397c2fbfb3SApril Chindone 407c2fbfb3SApril Chinfor ((i=0; i < 4; i++ )) 417c2fbfb3SApril Chindo j=0;for k in ${a[i][@]} 427c2fbfb3SApril Chin do [[ $k == "$i$j" ]] || err_exit "\${a[i][@]} != $i$j" 437c2fbfb3SApril Chin (( j++ )) 447c2fbfb3SApril Chin done 457c2fbfb3SApril Chindone 467c2fbfb3SApril Chinunset a 477c2fbfb3SApril China=( 487c2fbfb3SApril Chin ( 00 01 02 03 04 ) 497c2fbfb3SApril Chin ( 10 11 12 13 14 15) 507c2fbfb3SApril Chin ( 20 21 22 23 24 ) 517c2fbfb3SApril Chin ( 30 31 32 33 34 ) 527c2fbfb3SApril Chin) 537c2fbfb3SApril Chin 547c2fbfb3SApril Chinfunction check 557c2fbfb3SApril Chin{ 567c2fbfb3SApril Chin nameref a=$1 577c2fbfb3SApril Chin nameref b=a[2] 587c2fbfb3SApril Chin typeset c=$1 597c2fbfb3SApril Chin integer i j 607c2fbfb3SApril Chin for ((i=0; i < 4; i++ )) 617c2fbfb3SApril Chin do for ((j=0; j < 5; j++ )) 627c2fbfb3SApril Chin do [[ ${a[$i][$j]} == "$i$j" ]] || err_exit "\${$c[$i][$j]} != $i$j" 637c2fbfb3SApril Chin done 647c2fbfb3SApril Chin done 657c2fbfb3SApril Chin (( ${#a[@]} == 4 )) || err_exit "\${#$c[@]} not 4" 667c2fbfb3SApril Chin (( ${#a[0][@]} == 5 )) || err_exit "\${#$c[0][@]} not 5" 677c2fbfb3SApril Chin (( ${#a[1][@]} == 6 )) || err_exit "\${#$c[1][@]} not 6" 687c2fbfb3SApril Chin set -s -- ${!a[@]} 697c2fbfb3SApril Chin [[ ${@} == '0 1 2 3' ]] || err_exit "\${!$c[@]} not 0 1 2 3" 707c2fbfb3SApril Chin set -s -- ${!a[0][@]} 717c2fbfb3SApril Chin [[ ${@} == '0 1 2 3 4' ]] || err_exit "\${!$c[0][@]} not 0 1 2 3 4" 727c2fbfb3SApril Chin set -s -- ${!a[1][@]} 737c2fbfb3SApril Chin [[ ${@} == '0 1 2 3 4 5' ]] || err_exit "\${!$c[1][@]} not 0 1 2 3 4 5" 747c2fbfb3SApril Chin [[ $a == 00 ]] || err_exit "\$$c is not 00" 757c2fbfb3SApril Chin [[ ${a[0]} == 00 ]] || err_exit "\${$a[0]} is not 00" 767c2fbfb3SApril Chin [[ ${a[0][0]} == 00 ]] || err_exit "${a[0][0]} is not 00" 777c2fbfb3SApril Chin [[ ${a[0][0][0]} == 00 ]] || err_exit "\${$c[0][0][0]} is not 00" 787c2fbfb3SApril Chin [[ ${a[0][0][1]} == '' ]] || err_exit "\${$c[0][0][1]} is not empty" 797c2fbfb3SApril Chin [[ ${b[3]} == 23 ]] || err_exit "${!b}[3] not = 23" 807c2fbfb3SApril Chin} 817c2fbfb3SApril Chin 827c2fbfb3SApril Chincheck a 837c2fbfb3SApril Chin 847c2fbfb3SApril Chinunset a 857c2fbfb3SApril Chintypeset -A a 867c2fbfb3SApril Chinfor ((i=0; i < 4; i++ )) 877c2fbfb3SApril Chindo for ((j=0; j < 5; j++ )) 887c2fbfb3SApril Chin do a[$i][j]=$i$j 897c2fbfb3SApril Chin done 907c2fbfb3SApril Chindone 917c2fbfb3SApril Chinfor ((i=0; i < 4; i++ )) 927c2fbfb3SApril Chindo for ((j=0; j < 5; j++ )) 937c2fbfb3SApril Chin do [[ ${a[$i][j]} == "$i$j" ]] || err_exit "\${a[$i][$j]} == $i$j" 947c2fbfb3SApril Chin done 957c2fbfb3SApril Chindone 967c2fbfb3SApril China[1][5]=15 977c2fbfb3SApril Chinb=( 987c2fbfb3SApril Chin [0]=( 00 01 02 03 04 ) 997c2fbfb3SApril Chin [1]=( 10 11 12 13 14 15) 1007c2fbfb3SApril Chin [2]=( 20 21 22 23 24 ) 1017c2fbfb3SApril Chin [3]=( 30 31 32 33 34 ) 1027c2fbfb3SApril Chin) 1037c2fbfb3SApril Chincheck b 1047c2fbfb3SApril Chin[[ ${a[1][@]} == "${b[1][@]}" ]] || err_exit "a[1] not equal to b[1]" 1057c2fbfb3SApril Chinc=( 1067c2fbfb3SApril Chin [0]=( [0]=00 [1]=01 [2]=02 [3]=03 [4]=04 ) 1077c2fbfb3SApril Chin [1]=( [0]=10 [1]=11 [2]=12 [3]=13 [4]=14 [5]=15) 1087c2fbfb3SApril Chin [2]=( [0]=20 [1]=21 [2]=22 [3]=23 [4]=24 ) 1097c2fbfb3SApril Chin [3]=( [0]=30 [1]=31 [2]=32 [3]=33 [4]=34 ) 1107c2fbfb3SApril Chin) 1117c2fbfb3SApril Chincheck c 1127c2fbfb3SApril Chintypeset -A d 1137c2fbfb3SApril Chind[0]=( [0]=00 [1]=01 [2]=02 [3]=03 [4]=04 ) 1147c2fbfb3SApril Chind[1]=( [0]=10 [1]=11 [2]=12 [3]=13 [4]=14 [5]=15) 1157c2fbfb3SApril Chind[2]=( [0]=20 [1]=21 [2]=22 [3]=23 [4]=24 ) 1167c2fbfb3SApril Chind[3]=( [0]=30 [1]=31 [2]=32 [3]=33 [4]=34 ) 1177c2fbfb3SApril Chincheck d 1187c2fbfb3SApril Chinunset a b c d 1197c2fbfb3SApril Chin[[ ${a-set} ]] || err_exit "a is set after unset" 1207c2fbfb3SApril Chin[[ ${b-set} ]] || err_exit "b is set after unset" 1217c2fbfb3SApril Chin[[ ${c-set} ]] || err_exit "c is set after unset" 1227c2fbfb3SApril Chin[[ ${d-set} ]] || err_exit "c is set after unset" 1237c2fbfb3SApril Chinexit $((Errors)) 124