mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-05 11:21:53 +02:00
89 lines
1.5 KiB
Plaintext
89 lines
1.5 KiB
Plaintext
|
#!/bin/bash
|
||
|
. ./Common
|
||
|
|
||
|
###############################################################################
|
||
|
|
||
|
tst "substitutions: variable expansion $FOO" -ds -q <<EOF
|
||
|
!-s
|
||
|
FOO=x
|
||
|
BAR = \$FOO
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
FOO=x
|
||
|
BAR=\${FOO}
|
||
|
FOO=x
|
||
|
BAR=x
|
||
|
EOF
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
tst "substitutions: variable expansion ${FOO}bar" -ds -q <<EOF
|
||
|
!-s
|
||
|
FOO=x
|
||
|
BAR = \${FOO}bar
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
FOO=x
|
||
|
BAR=\${FOO}bar
|
||
|
FOO=x
|
||
|
BAR=xbar
|
||
|
EOF
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
tst_fail "substitutions: expand unknown variable" -ds <<EOF
|
||
|
!-s
|
||
|
BAR = \${FOO}
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
s:2: \$FOO may be undefined
|
||
|
EOF
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
tst "substitutions: expand variable used in match" -ds -q FOO=blah <<EOF
|
||
|
!-s
|
||
|
FOO = * { BAR = \$FOO }
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
FOO=RE {
|
||
|
BAR=\${FOO}
|
||
|
}
|
||
|
BAR=blah
|
||
|
EOF
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
tst_fail "substitutions: expand variable used in different branch" -ds <<EOF
|
||
|
!-s
|
||
|
FOO = * { BAR = \$FOO }
|
||
|
FOO = \$BAR
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
s:3: \$BAR may be undefined
|
||
|
EOF
|
||
|
|
||
|
#------------------------------------------------------------------------------
|
||
|
|
||
|
tst "substitutions: expand two variables" -ds -q <<EOF
|
||
|
!-s
|
||
|
FOO = a
|
||
|
BAR = b
|
||
|
FOO = \$FOO\$BAR
|
||
|
EOF
|
||
|
|
||
|
expect <<EOF
|
||
|
FOO=a
|
||
|
BAR=b
|
||
|
FOO=\${FOO}\${BAR}
|
||
|
FOO=ab
|
||
|
BAR=b
|
||
|
EOF
|
||
|
|
||
|
###############################################################################
|