]> git.saurik.com Git - bison.git/blame - tests/regression.at
* doc/refcard.tex: Update.
[bison.git] / tests / regression.at
CommitLineData
342b8b6e
AD
1# Bison Regressions. -*- Autotest -*-
2# Copyright 2001 Free Software Foundation, Inc.
c95f2d78 3
342b8b6e
AD
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
c95f2d78 8
342b8b6e
AD
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
c95f2d78 13
342b8b6e
AD
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17# 02111-1307, USA.
c95f2d78 18
342b8b6e 19AT_BANNER([[Regression tests.]])
c95f2d78
AD
20
21## ------------------ ##
22## Duplicate string. ##
23## ------------------ ##
24
25
26AT_SETUP([Duplicate string])
27
28AT_DATA([duplicate.y],
29[[/* `Bison -v' used to dump core when two tokens are defined with the same
30 string, as LE and GE below. */
31
32%token NUM
33%token LE "<="
34%token GE "<="
35
36%%
37exp: '(' exp ')' | NUM ;
38%%
39]])
40
41AT_CHECK([bison -v duplicate.y -o duplicate.c], 0, ignore, ignore)
42
43AT_CLEANUP([duplicate.*])
44
45
46
cd5aafcf
AD
47## ---------------------- ##
48## Mixing %token styles. ##
49## ---------------------- ##
50
51
52AT_SETUP([Mixing %token styles])
53
54# Taken from the documentation.
55AT_DATA([input.y],
56[[%token <operator> OR "||"
57%token <operator> LE 134 "<="
58%left OR "<="
59%%
60exp: ;
61%%
62]])
63
64AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore)
65
66AT_CLEANUP([input.*])
67
68
69
c95f2d78
AD
70## ---------------------- ##
71## %union and --defines. ##
72## ---------------------- ##
73
74
75AT_SETUP([%union and --defines])
76
77AT_DATA([union.y],
78[%union
79{
80 int integer;
81 char *string ;
82}
83%%
84exp: {};
85])
86
87AT_CHECK([bison --defines union.y])
88
89AT_CLEANUP([union.*])
342b8b6e
AD
90
91
92## --------------------------------------- ##
93## Duplicate '/' in C comments in %union ##
94## --------------------------------------- ##
95
96
97AT_SETUP([%union and C comments])
98
99AT_DATA([union-comment.y],
100[%union
101{
102 /* The int. */ int integer;
103 /* The string. */ char *string ;
104}
105%%
106exp: {};
107])
108
109AT_CHECK([bison union-comment.y])
110AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
111
112AT_CLEANUP([union-comment.*])
113
114
115## --------------- ##
116## invalid input. ##
117## --------------- ##
118
119
120AT_SETUP([Invalid input])
121
122AT_DATA([input.y],
123[[%%
124?
125]])
126
127AT_CHECK([bison input.y], [1], [],
128[input.y:2: invalid input: `?'
129input.y:3: fatal error: no rules in the input grammar
130])
131
132AT_CLEANUP
133
134
561f9a30
AD
135## ----------------- ##
136## Invalid input 1. ##
137## ----------------- ##
138
139
140AT_SETUP([Invalid input: 1])
141
142AT_DATA([input.y],
143[[%%
144?
145]])
146
147AT_CHECK([bison input.y], [1], [],
148[input.y:2: invalid input: `?'
149input.y:3: fatal error: no rules in the input grammar
150])
151
152AT_CLEANUP
153
154
155## ----------------- ##
156## Invalid input 2. ##
157## ----------------- ##
158
159
160AT_SETUP([Invalid input: 2])
161
162AT_DATA([input.y],
163[[%%
164default: 'a' }
165]])
166
167AT_CHECK([bison input.y], [1], [],
168[input.y:2: invalid input: `}'
169])
170
171AT_CLEANUP
172
173
270a173c 174
342b8b6e
AD
175## --------------------- ##
176## Invalid CPP headers. ##
177## --------------------- ##
178
270a173c
AD
179# AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
180# -------------------------------------
181m4_define([AT_TEST_CPP_GUARD_H],
182[AT_SETUP([Invalid CPP guards: $1])
342b8b6e 183
270a173c
AD
184# possibly create and nuke inner directories.
185m4_bmatch([$1], [[/]],
186[dirname=`AS_DIRNAME([$1])`
187AS_MKDIR_P([$dirname])
188AT_CLEANUP_FILES([$dirname])])
342b8b6e 189
270a173c 190AT_DATA([$1.y],
342b8b6e
AD
191[%%
192dummy:
193])
194
270a173c 195AT_CHECK([bison --defines=$1.h $1.y])
342b8b6e 196
270a173c
AD
197# CPP should be happy with it.
198AT_CHECK([$CC -E $1.h], 0, [ignore])
199
200AT_CLEANUP($1.y)
201])
342b8b6e 202
270a173c
AD
203AT_TEST_CPP_GUARD_H([input/input])
204AT_TEST_CPP_GUARD_H([9foo])