-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-t-bad.sh
executable file
·95 lines (85 loc) · 2.08 KB
/
test-t-bad.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /bin/sh
# UCLA CS 111 Lab 1 - Test that syntax errors are caught.
# Copyright 2012-2014 Paul Eggert.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
tmp=$0-$$.tmp
mkdir "$tmp" || exit
(
cd "$tmp" || exit
status=
# Sanity check, to make sure it works with at least one good example.
echo x >test0.sh || exit
../profsh -t test0.sh >test0.out 2>test0.err || exit
echo '# 1
x' >test0.exp || exit
diff -u test0.exp test0.out || exit
test ! -s test0.err || {
cat test0.err
exit 1
}
n=1
for bad in \
'`' \
'>' \
'<' \
'a >b <' \
';' \
'; a' \
'a ||' \
'while a' \
'do' \
'done >it' \
'if a; then b; else fi' \
'if ; then ; else ; fi' \
'if a; else b; then c; fi' \
'if a; then b' \
'if a; then b; else c; ); fi' \
'if a; then b; ) else c; fi' \
'if a); then b; else c; fi' \
'if (); then b; else c; fi' \
'if a; then b; else c; fi fi' \
'if a; then b; else c; done' \
'while a; do b; done ouch' \
'until a; do b; done >' \
'a
| b' \
'a
; b' \
'a;;b' \
'a|||b' \
'|a' \
'< a' \
'&& a' \
'||a' \
'(a|b' \
'a;b)' \
'( (a)' \
'a>>>b' \
'while a; do b; done; | c' \
'if b; then (c | d; else e); fi' \
'a<b>c<d' \
'until b;c;; do d; done'
do
echo "$bad" >test$n.sh || exit
../profsh -t test$n.sh >test$n.out 2>test$n.err && {
echo >&2 "test$n: unexpectedly succeeded for: $bad"
status=1
}
test -s test$n.err || {
echo >&2 "test$n: no error message for: $bad"
status=1
}
n=$((n+1))
done
exit $status
) || exit
rm -fr "$tmp"