mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 07:54:06 +02:00
b2/test/subbreak: test "break" in substitutions
This commit is contained in:
parent
ddbf80b542
commit
fa20078840
153
b2/test/subbreak
Executable file
153
b2/test/subbreak
Executable 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
|
||||
|
||||
###############################################################################
|
Loading…
Reference in New Issue
Block a user