]> git.saurik.com Git - bison.git/blame - examples/calc++/test
Fail on parse error in calc++.
[bison.git] / examples / calc++ / test
CommitLineData
0ffd4fd1 1#! /bin/sh
828c373b 2
a1b3bf8c
AD
3test -z "$VERBOSE" && {
4 exec > /dev/null 2>&1
d4476375 5 set -x
a1b3bf8c
AD
6}
7
414c76a4
AD
8me=`basename $0`
9
10# Number of the current test.
11number=1
12
13# Exit status of this script.
14exit=true
15
16# run EXPECTED-EXIT-STATUS [PARSER-OPTIONS]
17# -----------------------------------------
18run ()
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
0ffd4fd1
AD
35cat >input <<EOF
36a := 1
37b := 2
38c := 3
39d := a + b * c
40d
41EOF
414c76a4
AD
42run 0
43run 0 -p
0ffd4fd1 44
0ffd4fd1
AD
45
46cat >input <<EOF
47a := 1
48d := a + b * c
49EOF
414c76a4
AD
50run 1 input
51
0ffd4fd1 52
0ffd4fd1
AD
53cat >input <<EOF
54toto := 1
55toto
56EOF
414c76a4 57run 0 -s
828c373b
AD
58
59rm input
414c76a4 60$exit