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