1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-18 02:36:17 +02:00
eda-tools/b2/test/subcont

155 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
. ./Common
###############################################################################
tst "substitutions: continue" -ds -q <<EOF
!-s
in = blah
out = x
in = (?)(*) {
out = \$out\$1\$1
in = \$2
continue
}
EOF
expect <<EOF
in=blah
out=x
in=RE {
out=\${out}\$1\$1
in=\$2
continue in
}
in=
out=xbbllaahh
EOF
#------------------------------------------------------------------------------
tst "substitutions: named continue to inner block" -q x=abc <<EOF
!-s
z = x
x = (?)(*) {
x = \$2
y = \$x
y = (*)(?) {
z = \$z\$y\$2
y = \$1
continue y
}
}
EOF
expect <<EOF
z=xbccbb
x=bc
y=
EOF
#------------------------------------------------------------------------------
tst "substitutions: named continue to outer block" -q x=abc <<EOF
!-s
z = x
x = (?)(*) {
x = \$2
y = \$x
y = (*)(?) {
z = \$z\$y\$2
y = \$1
continue x
}
}
EOF
expect <<EOF
z=xbcccc
x=
y=
EOF
#------------------------------------------------------------------------------
tst "substitutions: continue to \$" -ds -q <<EOF
!-s
in = blah
out = x
in = ?(*) {
in = \$1
out = \${out}+
continue \$
}
EOF
expect <<EOF
in=blah
out=x
in=RE {
in=\$1
out=\${out}+
continue in
}
in=
out=x++++
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: unnamed continue inside block" <<EOF
!-s
foo = * {
continue
bar = x
}
EOF
expect <<EOF
s:3: syntax error
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: named continue inside block" <<EOF
!-s
foo = * {
continue foo
bar = x
}
EOF
expect <<EOF
s:4: unreachable code
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: named continue to unknown block" -q <<EOF
!-s
x = foo
x = * {
y = \$x
y = * {
continue z
}
}
EOF
expect <<EOF
s:8: cannot find "z"
EOF
#------------------------------------------------------------------------------
tst_fail "substitutions: continue without block" -q <<EOF
!-s
continue
EOF
expect <<EOF
s:2: jump without block
EOF
###############################################################################