1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-02 21:19:22 +02:00
eda-tools/b2/test/subcont
Werner Almesberger ed8df3f94e b2/test/sub{break,cont}: code after named and unnamed jump is handled differently
Now we handle both code paths. Should probably unify the diagnostic some
day, too.
2012-06-03 21:17:31 -03:00

155 lines
2.1 KiB
Bash
Executable File

#!/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
###############################################################################