]>
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 | ||
414c76a4 AD |
18 | me=`basename $0` |
19 | ||
20 | # Number of the current test. | |
21 | number=1 | |
22 | ||
23 | # Exit status of this script. | |
24 | exit=true | |
25 | ||
2e4986a8 AD |
26 | # The exercised program. |
27 | prog=./examples/calc++/calc++ | |
28 | ||
1a7a65f9 AD |
29 | # run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS] |
30 | # --------------------------------------------------------- | |
414c76a4 AD |
31 | run () |
32 | { | |
33 | # Effective and expected exit status. | |
34 | local sta_exp=$1 | |
35 | shift | |
1a7a65f9 AD |
36 | local out_exp=$1 |
37 | shift | |
2e4986a8 | 38 | $prog "$@" - <input >out_eff |
414c76a4 | 39 | local sta_eff=$? |
1a7a65f9 | 40 | local out_eff=`cat out_eff` |
414c76a4 | 41 | if test $sta_eff -eq $sta_exp; then |
1a7a65f9 AD |
42 | if test "$out_eff" = "$out_exp"; then |
43 | printf "$me: PASS: %2d\n" $number | |
44 | else | |
45 | printf "$me: FAIL: %2d (expected output: %s, effective: %s\n" \ | |
46 | $number "$out_exp" "$out_eff" | |
47 | exit=false | |
48 | fi | |
414c76a4 AD |
49 | else |
50 | printf "$me: FAIL: %2d (expected status: %d, effective: %d\n" \ | |
51 | $number $sta_exp $sta_eff | |
52 | exit=false | |
53 | fi | |
54 | number=`expr $number + 1` | |
55 | } | |
56 | ||
2e4986a8 AD |
57 | |
58 | cat >input <<EOF | |
59 | toto := 1 | |
60 | toto | |
61 | EOF | |
62 | run 0 1 -s | |
63 | ||
64 | ||
0ffd4fd1 AD |
65 | cat >input <<EOF |
66 | a := 1 | |
67 | b := 2 | |
68 | c := 3 | |
69 | d := a + b * c | |
70 | d | |
71 | EOF | |
1a7a65f9 AD |
72 | run 0 7 |
73 | run 0 7 -p | |
74 | ||
75 | ||
76 | cat >input <<EOF | |
77 | a := 1 | |
78 | b := 2 | |
79 | c := 3 | |
80 | d := (a + b) * c | |
81 | d | |
82 | EOF | |
83 | run 0 9 | |
0ffd4fd1 | 84 | |
0ffd4fd1 AD |
85 | |
86 | cat >input <<EOF | |
87 | a := 1 | |
88 | d := a + b * c | |
89 | EOF | |
2e4986a8 | 90 | run 1 '' |
828c373b | 91 | |
1a7a65f9 | 92 | rm input out_eff |
414c76a4 | 93 | $exit |