1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 02:30:36 +02:00

b2/test/subbreak: test "break" in substitutions

This commit is contained in:
Werner Almesberger 2012-06-03 20:59:10 -03:00
parent ddbf80b542
commit fa20078840

153
b2/test/subbreak Executable file
View File

@ -0,0 +1,153 @@
#!/bin/bash
. ./Common
###############################################################################
tst "substitutions: break alone" -ds -q <<EOF
!-s
in = blah
out = x
in = (?)(*) {
out=\$out\$in
break /* does nothing useful */
}
EOF
expect <<EOF
in=blah
out=x
in=RE {
out=\${out}\${in}
break in
}
in=blah
out=xblah
EOF
#------------------------------------------------------------------------------
tst "substitutions: named break to inner block" -ds -q <<EOF
!-s
in = blah
out = x
in = (?)(*) {
out=\$out\$in
break in /* does nothing useful */
}
EOF
expect <<EOF
in=blah
out=x
in=RE {
out=\${out}\${in}
break in
}
in=blah
out=xblah
EOF
#------------------------------------------------------------------------------
tst "substitutions: named break to outer block (taken)" -q doit=y <<EOF
!-s
in = blah
out = x
in = (?)(*) {
out=\$out\$in
doit = y {
break in
}
out=\$out\$in
}
EOF
expect <<EOF
in=blah
out=xblah
EOF
#------------------------------------------------------------------------------
tst "substitutions: named break to outer block (not taken)" -q doit=n <<EOF
!-s
in = blah
out = x
in = (?)(*) {
out=\$out\$in
doit = y {
break in
}
out=\$out\$in
}
EOF
expect <<EOF
in=blah
out=xblahblah
EOF
#------------------------------------------------------------------------------
tst "substitutions: break with continue" -q <<EOF
!-s
res = x
res = * {
res = \${res}x
/*
* We use a temporary variable here because the variable name also
* serves as a jump label. Alternatively, we could use a dummy
* variable for the outer block.
*/
tmp = \$res
tmp = ????? { break res }
continue
}
EOF
expect <<EOF
res=xxxxx
tmp=xxxxx
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: break inside block " -q <<EOF
!-s
foo = x
foo = * {
break bar
foo = x
}
EOF
expect <<EOF
s:5: unreachable code
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: named break to unknown block" -q <<EOF
!-s
foo = x
foo = * {
break bar
}
EOF
expect <<EOF
s:5: cannot find "bar"
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: break without block" -q <<EOF
!-s
break
EOF
expect <<EOF
s:2: jump without block
EOF
###############################################################################