sh: Add some parser tests.
case1.0 tests POSIX requirements and one more for keywords in case statements. The others test very special cases of command substitution. These also work on stable/8.
This commit is contained in:
parent
684507e744
commit
c0ec19525d
14
tools/regression/bin/sh/parser/case1.0
Normal file
14
tools/regression/bin/sh/parser/case1.0
Normal file
@ -0,0 +1,14 @@
|
||||
# $FreeBSD$
|
||||
|
||||
keywords='if then else elif fi while until for do done { } case esac ! in'
|
||||
|
||||
# Keywords can be used unquoted in case statements, except the keyword
|
||||
# esac as the first pattern of a '|' alternation without a starting '('.
|
||||
# (POSIX doesn't seem to require (esac) to work.)
|
||||
for k in $keywords; do
|
||||
eval "case $k in (foo|$k) ;; *) echo bad ;; esac"
|
||||
eval "case $k in ($k) ;; *) echo bad ;; esac"
|
||||
eval "case $k in foo|$k) ;; *) echo bad ;; esac"
|
||||
[ "$k" = esac ] && continue
|
||||
eval "case $k in $k) ;; *) echo bad ;; esac"
|
||||
done
|
32
tools/regression/bin/sh/parser/case2.0
Normal file
32
tools/regression/bin/sh/parser/case2.0
Normal file
@ -0,0 +1,32 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Pretty much only ash derivatives can parse all of this.
|
||||
|
||||
f1() {
|
||||
x=$(case x in
|
||||
(x|esac) ;;
|
||||
(*) echo bad >&2 ;;
|
||||
esac)
|
||||
}
|
||||
f1
|
||||
f2() {
|
||||
x=$(case x in
|
||||
(x|esac) ;;
|
||||
(*) echo bad >&2
|
||||
esac)
|
||||
}
|
||||
f2
|
||||
f3() {
|
||||
x=$(case x in
|
||||
x|esac) ;;
|
||||
*) echo bad >&2 ;;
|
||||
esac)
|
||||
}
|
||||
f3
|
||||
f4() {
|
||||
x=$(case x in
|
||||
x|esac) ;;
|
||||
*) echo bad >&2
|
||||
esac)
|
||||
}
|
||||
f4
|
7
tools/regression/bin/sh/parser/heredoc3.0
Normal file
7
tools/regression/bin/sh/parser/heredoc3.0
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# This may be expected to work, but pretty much only ash derivatives allow it.
|
||||
|
||||
test "$(cat <<EOF)" = "hi there"
|
||||
hi there
|
||||
EOF
|
Loading…
x
Reference in New Issue
Block a user