mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2025-04-21 12:27:27 +03:00
b2/test/: add first set of substitution tests
This commit is contained in:
88
b2/test/subvar
Executable file
88
b2/test/subvar
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/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
|
||||
|
||||
###############################################################################
|
||||
Reference in New Issue
Block a user