1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # test suite cribbed from ksh93 nameref tests
20 if [[ $one != $2 ]]; then
21 echo "one=$one != 2=$2"
28 typeset -n one=$1 two=$2
30 if [[ $one != $two ]]; then
31 echo "one=$one != two=$two"
67 # XXX - need to see if we can do checks for self-referencing at assignment
69 command typeset -n xx=yy
70 command typeset -n yy=xx
80 # XXX -- another self-referencing error?
81 # ksh93 makes this another invalid self-reference
101 # assignment to a previously-unset variable
102 typeset -n short=long
111 # simple array references and assignments
133 # should ref at global scope survive call to foobar()?
149 # assignment in a function to something possibly out of scope
157 assignvar lex a b c d e
158 echo "expect <a b c d e>"
161 unset foo bar short long
163 typeset -n foo='x[2]'
165 x=(zero one two three four)
168 echo "expect <zero> <one> <seven> <three> <four>"
176 # make sure nameref to a previously-unset variable creates the variable
180 # make sure they work inside arithmetic expressions
181 unset foo bar ref x xxx
201 # should the reference do immediate evaluation or deferred?
202 set -- one two three four
204 # XXX - what does foo get set to here?
205 typeset -n foo='bar[0]'
214 # Need to add code and tests for nameref to array subscripts
215 bar=(one two three four)
217 typeset -n foo='bar[0]'
218 typeset -n qux='bar[3]'
231 # Need to add code and tests for `for' loop nameref variables
233 echo errors = $errors