]>
Commit | Line | Data |
---|---|---|
0ffd4fd1 | 1 | #! /bin/sh |
828c373b | 2 | |
3272a725 AD |
3 | # Copyright (C) 2005-2012 Free Software Foundation, Inc. |
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
c3a2e0e6 AD |
18 | me=`dirname $0` |
19 | me=`basename $me` | |
414c76a4 AD |
20 | |
21 | # Number of the current test. | |
22 | number=1 | |
23 | ||
24 | # Exit status of this script. | |
25 | exit=true | |
26 | ||
2e4986a8 | 27 | # The exercised program. |
c3a2e0e6 AD |
28 | prog=../examples/$me/$me |
29 | ||
30 | # cleanup | |
31 | # ------- | |
32 | cleanup () | |
33 | { | |
34 | local status=$? | |
35 | if test -z "$DEBUG"; then | |
36 | cd .. | |
37 | rm -rf $$.dir | |
38 | fi | |
39 | exit $status | |
40 | } | |
41 | trap cleanup 0 1 2 13 15 | |
42 | mkdir $$.dir | |
43 | cd $$.dir | |
2e4986a8 | 44 | |
1a7a65f9 AD |
45 | # run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS] |
46 | # --------------------------------------------------------- | |
414c76a4 AD |
47 | run () |
48 | { | |
c3a2e0e6 | 49 | # Expected exit status. |
414c76a4 AD |
50 | local sta_exp=$1 |
51 | shift | |
c3a2e0e6 | 52 | # Expected output. |
1a7a65f9 AD |
53 | local out_exp=$1 |
54 | shift | |
2e4986a8 | 55 | $prog "$@" - <input >out_eff |
c3a2e0e6 | 56 | # Effective exit status. |
414c76a4 | 57 | local sta_eff=$? |
c3a2e0e6 | 58 | # Effective output. |
1a7a65f9 | 59 | local out_eff=`cat out_eff` |
414c76a4 | 60 | if test $sta_eff -eq $sta_exp; then |
1a7a65f9 | 61 | if test "$out_eff" = "$out_exp"; then |
c3a2e0e6 | 62 | echo "$me: PASS: $number" |
1a7a65f9 | 63 | else |
c3a2e0e6 | 64 | echo "$me: FAIL: $number (expected output: $out_exp, effective: $out_eff)" |
1a7a65f9 AD |
65 | exit=false |
66 | fi | |
414c76a4 | 67 | else |
c3a2e0e6 | 68 | echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)" |
414c76a4 AD |
69 | exit=false |
70 | fi | |
71 | number=`expr $number + 1` | |
72 | } | |
73 | ||
2e4986a8 AD |
74 | |
75 | cat >input <<EOF | |
76 | toto := 1 | |
77 | toto | |
78 | EOF | |
79 | run 0 1 -s | |
80 | ||
81 | ||
0ffd4fd1 AD |
82 | cat >input <<EOF |
83 | a := 1 | |
84 | b := 2 | |
85 | c := 3 | |
86 | d := a + b * c | |
87 | d | |
88 | EOF | |
1a7a65f9 AD |
89 | run 0 7 |
90 | run 0 7 -p | |
91 | ||
92 | ||
93 | cat >input <<EOF | |
94 | a := 1 | |
95 | b := 2 | |
96 | c := 3 | |
97 | d := (a + b) * c | |
98 | d | |
99 | EOF | |
100 | run 0 9 | |
0ffd4fd1 | 101 | |
0ffd4fd1 AD |
102 | |
103 | cat >input <<EOF | |
104 | a := 1 | |
105 | d := a + b * c | |
106 | EOF | |
2e4986a8 | 107 | run 1 '' |
828c373b | 108 | |
414c76a4 | 109 | $exit |