2012-06-03 19:32:13 +03:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2012-06-04 03:17:31 +03:00
|
|
|
tst_fail "substitutions: unnamed continue inside block" <<EOF
|
2012-06-03 19:32:13 +03:00
|
|
|
!-s
|
|
|
|
foo = * {
|
|
|
|
continue
|
|
|
|
bar = x
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
s:3: syntax error
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2012-06-04 03:17:31 +03:00
|
|
|
tst_fail "substitutions: named continue inside block" <<EOF
|
|
|
|
!-s
|
|
|
|
foo = * {
|
|
|
|
continue foo
|
|
|
|
bar = x
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
s:4: unreachable code
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2012-06-03 19:32:13 +03:00
|
|
|
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
|
|
|
|
|
2012-06-04 02:54:08 +03:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tst_fail "substitutions: continue without block" -q <<EOF
|
|
|
|
!-s
|
|
|
|
continue
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
s:2: jump without block
|
|
|
|
EOF
|
|
|
|
|
2012-06-03 19:32:13 +03:00
|
|
|
###############################################################################
|