1 # Bison Regressions. -*- Autotest -*-
2 # Copyright 2001 Free Software Foundation, Inc.
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)
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.
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
19 AT_BANNER([[Regression tests.]])
21 ## ------------------ ##
22 ## Duplicate string. ##
23 ## ------------------ ##
26 AT_SETUP([Duplicate string])
28 AT_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. */
37 exp: '(' exp ')' | NUM ;
41 AT_CHECK([bison -v duplicate.y -o duplicate.c], 0, ignore, ignore)
43 AT_CLEANUP([duplicate.*])
47 ## ---------------------- ##
48 ## Mixing %token styles. ##
49 ## ---------------------- ##
52 AT_SETUP([Mixing %token styles])
54 # Taken from the documentation.
56 [[%token <operator> OR "||"
57 %token <operator> LE 134 "<="
64 AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore)
70 ## ---------------------- ##
71 ## %union and --defines. ##
72 ## ---------------------- ##
75 AT_SETUP([%union and --defines])
87 AT_CHECK([bison --defines union.y])
92 ## --------------------------------------- ##
93 ## Duplicate '/' in C comments in %union ##
94 ## --------------------------------------- ##
97 AT_SETUP([%union and C comments])
99 AT_DATA([union-comment.y],
102 /* The int. */ int integer;
103 /* The string. */ char *string ;
109 AT_CHECK([bison union-comment.y])
110 AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
112 AT_CLEANUP([union-comment.*])
115 ## --------------- ##
117 ## --------------- ##
120 AT_SETUP([Invalid input])
127 AT_CHECK([bison input.y], [1], [],
128 [input.y:2: invalid input: `?'
129 input.y:3: fatal error: no rules in the input grammar
135 ## ----------------- ##
136 ## Invalid input 1. ##
137 ## ----------------- ##
140 AT_SETUP([Invalid input: 1])
147 AT_CHECK([bison input.y], [1], [],
148 [input.y:2: invalid input: `?'
149 input.y:3: fatal error: no rules in the input grammar
155 ## ----------------- ##
156 ## Invalid input 2. ##
157 ## ----------------- ##
160 AT_SETUP([Invalid input: 2])
167 AT_CHECK([bison input.y], [1], [],
168 [input.y:2: invalid input: `}'
175 ## --------------------- ##
176 ## Invalid CPP headers. ##
177 ## --------------------- ##
179 # AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
180 # -------------------------------------
181 m4_define([AT_TEST_CPP_GUARD_H],
182 [AT_SETUP([Invalid CPP guards: $1])
184 # possibly create and nuke inner directories.
185 m4_bmatch([$1], [[/]],
186 [dirname=`AS_DIRNAME([$1])`
187 AS_MKDIR_P([$dirname])
188 AT_CLEANUP_FILES([$dirname])])
195 AT_CHECK([bison --defines=$1.h $1.y])
197 # CPP should be happy with it.
198 AT_CHECK([$CC -E $1.h], 0, [ignore])
203 AT_TEST_CPP_GUARD_H([input/input])
204 AT_TEST_CPP_GUARD_H([9foo])