]> git.saurik.com Git - bison.git/blob - examples/calc++/test
Fail on parse error in calc++.
[bison.git] / examples / calc++ / test
1 #! /bin/sh
2
3 test -z "$VERBOSE" && {
4 exec > /dev/null 2>&1
5 set -x
6 }
7
8 me=`basename $0`
9
10 # Number of the current test.
11 number=1
12
13 # Exit status of this script.
14 exit=true
15
16 # run EXPECTED-EXIT-STATUS [PARSER-OPTIONS]
17 # -----------------------------------------
18 run ()
19 {
20 # Effective and expected exit status.
21 local sta_exp=$1
22 shift
23 ./calc++ "$@" input
24 local sta_eff=$?
25 if test $sta_eff -eq $sta_exp; then
26 printf "$me: PASS: %2d\n" $number
27 else
28 printf "$me: FAIL: %2d (expected status: %d, effective: %d\n" \
29 $number $sta_exp $sta_eff
30 exit=false
31 fi
32 number=`expr $number + 1`
33 }
34
35 cat >input <<EOF
36 a := 1
37 b := 2
38 c := 3
39 d := a + b * c
40 d
41 EOF
42 run 0
43 run 0 -p
44
45
46 cat >input <<EOF
47 a := 1
48 d := a + b * c
49 EOF
50 run 1 input
51
52
53 cat >input <<EOF
54 toto := 1
55 toto
56 EOF
57 run 0 -s
58
59 rm input
60 $exit