]> git.saurik.com Git - bison.git/blame - tests/regression.at
* tests/regression.at (AT_TEST_CPP_GUARD_H): New.
[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
47## ---------------------- ##
48## %union and --defines. ##
49## ---------------------- ##
50
51
52AT_SETUP([%union and --defines])
53
54AT_DATA([union.y],
55[%union
56{
57 int integer;
58 char *string ;
59}
60%%
61exp: {};
62])
63
64AT_CHECK([bison --defines union.y])
65
66AT_CLEANUP([union.*])
342b8b6e
AD
67
68
69## --------------------------------------- ##
70## Duplicate '/' in C comments in %union ##
71## --------------------------------------- ##
72
73
74AT_SETUP([%union and C comments])
75
76AT_DATA([union-comment.y],
77[%union
78{
79 /* The int. */ int integer;
80 /* The string. */ char *string ;
81}
82%%
83exp: {};
84])
85
86AT_CHECK([bison union-comment.y])
87AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
88
89AT_CLEANUP([union-comment.*])
90
91
92## --------------- ##
93## invalid input. ##
94## --------------- ##
95
96
97AT_SETUP([Invalid input])
98
99AT_DATA([input.y],
100[[%%
101?
102]])
103
104AT_CHECK([bison input.y], [1], [],
105[input.y:2: invalid input: `?'
106input.y:3: fatal error: no rules in the input grammar
107])
108
109AT_CLEANUP
110
111
561f9a30
AD
112## ----------------- ##
113## Invalid input 1. ##
114## ----------------- ##
115
116
117AT_SETUP([Invalid input: 1])
118
119AT_DATA([input.y],
120[[%%
121?
122]])
123
124AT_CHECK([bison input.y], [1], [],
125[input.y:2: invalid input: `?'
126input.y:3: fatal error: no rules in the input grammar
127])
128
129AT_CLEANUP
130
131
132## ----------------- ##
133## Invalid input 2. ##
134## ----------------- ##
135
136
137AT_SETUP([Invalid input: 2])
138
139AT_DATA([input.y],
140[[%%
141default: 'a' }
142]])
143
144AT_CHECK([bison input.y], [1], [],
145[input.y:2: invalid input: `}'
146])
147
148AT_CLEANUP
149
150
270a173c 151
342b8b6e
AD
152## --------------------- ##
153## Invalid CPP headers. ##
154## --------------------- ##
155
270a173c
AD
156# AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
157# -------------------------------------
158m4_define([AT_TEST_CPP_GUARD_H],
159[AT_SETUP([Invalid CPP guards: $1])
342b8b6e 160
270a173c
AD
161# possibly create and nuke inner directories.
162m4_bmatch([$1], [[/]],
163[dirname=`AS_DIRNAME([$1])`
164AS_MKDIR_P([$dirname])
165AT_CLEANUP_FILES([$dirname])])
342b8b6e 166
270a173c 167AT_DATA([$1.y],
342b8b6e
AD
168[%%
169dummy:
170])
171
270a173c 172AT_CHECK([bison --defines=$1.h $1.y])
342b8b6e 173
270a173c
AD
174# CPP should be happy with it.
175AT_CHECK([$CC -E $1.h], 0, [ignore])
176
177AT_CLEANUP($1.y)
178])
342b8b6e 179
270a173c
AD
180AT_TEST_CPP_GUARD_H([input/input])
181AT_TEST_CPP_GUARD_H([9foo])